Java Programming (22412)
int [] intArray = new int[20};
2. Multi Dimensional
Example:
int{][] intArray = new int{10}{20]; //a 2D array or matrix
int{](J0) intArray = new int{10}[20][10]; //a 3D array
VIII. Resources required(Additional)
Nil
IX. Resources used (Additional)
Sr. Name of Broad Quantity Remarks
No. Resource Specification (@ifany)
1S = as
1
€/s'2 GBI
2 | Sw V5 Cocle a ~
iy Tov
X. Program Code: Teacher must assign a separate program statement to group of 3-
4 students.
Write a program to implement multidimensional array.
closs Testonrery
t rable static void mun (Stang SLJ)
tol af T= new rntlse
ale} = to;
alr} = 20)
ale} = a8;
50;
Gnt iso) (eq length; 44)
$.0-plaly) yf
Maharashira State Board of Technical Education 61Java Programmi IC ee
NL Result (Output of Code): 10
XU. Practical Reta westions
Note: Below pen ‘are few sample questions for reference. Teacher mug
more such questions so as to ensure the achievement of identified CO.
1. What is use of new operator in defining an array?
2. In 2D array which dimension is optional at the declaration of array?
3. Is itpossible to change size of array once allocated?
4. State the situation where Index Out of Bounds Exception will be generated,
dep
(Space for answer)
4f
Java Programming (22412)
XII. Exercis
1. Write output/error of code in the given space.
Sr.
Nat Program Code OutputError
State line no and error.
classTest2 {
public static void main(String{] args) { 4 err ons
i: inta{] = new int{5]; //line 1
int{] arr = new int{]; line 2
class Tests {
public static void main(String[] args) { Cl@ec 4
int arr[] = new int[5]; Bb
2 System.out printin(ar);
System.out.printin(arr[0]);
}
}
|. Write a program to display array elements using for-each loop.
Lu ee for answer)
each.
kn Ln
plte.....babee....ucatel
pore eee
Maharashtra State Board of Technical Education aJava Programming (22412)
: Returns enumeration of components of tis —~
6. | Enumeration elements() vector ]
7,_| Object firstElement() Returns first component of this vector
8._| Object lastElement() Returns last component of this vector
a ‘Searches for the first occurrence of given
9. | int indexoftObject elem) ccqument. j
To, | YoldinseriElementAi(Object — | Inserts specified object as a component atthe
+ | obj, int index) specified index position.
11, | void removeElementAt(int Removes the element at specified position in the
~ | index) vector
1p, | boolean Removes first occurrence of the argument from
"| removeElement(Object obj) _| the vector
13._| int sizeQ) Returns number of components in the vector
14. | void copylnto(Object( aay) Coie the components of vector into specified
VIII. Resources required(Additional)
Nil
IX. Resources used (Additional)
Sr] Name of 5
Niall Riseutce Broad Specification Quantity Tara.
Tre iS =
5 § |52 GP ’
p/ w Toe ; e
xX Pi 7 i
ae fo Teacher must assign a separate program statement to group of 3-
Write a program to insert different elements in the Vector and display them.
Import Suva uel #5
cless Maun ( a
public stabeved men Cgtarng sCI){
Vets tig? mom = new vec bore7l
maynm /arodal "O09";
mamin. ad ("a14);
Mamyn. adel 02,6 ¢ ob;
S.0. PU Nee 4 eee
J
3
‘Maharashtra State Board of Technical Educat Sa ere wc eet eee td3)
__ Maharashtra State Board of Technical Education
Java Programming (22412)
xr. bein of Code):
XII. Practical Related Questions
Note: Below given are few sample questions for reference. Teacher mast design
more such questions so as to ensure the achievement of identified CO.
1. State difference between size() and capacity() method of Vector class.
- Differentiate between addElement() and insertElementAt() methods of Vector
class.
3. Differentiate between array and Vector.
(Space for answer)Java Programming (22412)
XIII. Exercise:
Sr.
No.
Program Code
Output
* import java.utl.*;
class demol {
public static Void main(String{] args)
Vector v = new Vector(20);
System.out printin(v.capacity);
System.out.printin(v.size();
}
i
26.4
1. Write a program to use different methods of Vector class,
(Space for answer)
Vanarashira State Hoard of Technical Educationre
suo Progamming (22412)
© | intValueQ) Fetums the value of this Integer as an int
7_|shortValueQ)_ Fetums the value of this Integer as a short
$_| longValue() Tetums the value of this Integer as a long
9. | int compareTo(int i)
Compares the numerical value of the invoking object
with that of i, Retums 0 if the values are equal. Returns
a negative value if the invoking object has a lower
value. Retums a positive value if the invoking object
has a greater value.
10 static int compare(int
numl, int num2)
Compares the values of numi and num2. Retums 0 if
the values are equal. Returns a negative value if num]
is less than num2. Retums a positive value if num] is
greater than num2.
11 | boolean equals(Object
intObj)
Returns true if the invoking Integer object is equivalent
to intObj. Otherwise, it retums false.
‘Similar Wrapper class methods are available for Float, Short, Long and Double class.
VII. Resources required(Additional)
Nil
IX. Resources used (Additional)
Bo | ee Name of Broad Specification | Quantity | Remarks (If any)
No. | _ Resource
1 1S =
ive 8/512 Gr '
7 | S/w JeK , Vv zs -
X. Program Code: Teacher must assign a separate program statement to group of 3-
4 students.
Write a program to show the use of Integer Wrapper class methods.
guoiic class
W xappet {
‘public stable void moun lSbving scent
jn 4220; p
Inkeger into =);
5.0 .0Cinto)
ee
abstr Sate Board of Technveal Education 7oySta ee aera aa a
aa
Java Programming (22412)
XI Result (Output of Code):
XI. ieee Questions
Note: Below given are few sample questions for reference. Teacher myy,
‘more such questions so as to ensure the achievement of identified CO,
1. Write a different ways to create object of the any primitive datatype,
2. Write methods of Number class to convert object into primitive datatype,
3, List all Wrapper classes in Java.
(Space for answer)
Tira State Board of Technical Educationrr
ya OER (22412)
NII Exercise:
1. Write a program to convert String value into Integer Wrapper class object.
2. Write a program to make use of Character Wrapper class methods.
3. Write a program to convert Integer object value into primitive datatype byte, short
and double value.
(Space for answer)
fig
“GNRGRGa Susie Board of Technical Baveation B
[aMp I
Java Programming (22412)
> Parent Class
-——————__| Overriden method
Inherited method
addition()
calculateQ)
|___-» SubClass
B
data2 Overriding method
display.
Fig. 5 Overriding of Methods
VII. Resources required (Additional)
Nil
IX. _ Resources used (Additional)
x ame or Broad Specification | Quantity | Remarks (fan)
tT oc 15 )
SISIZ ER ~
2 lols BC Z
ode -
x.
Program Code: Teacher must assign a separate program statement to group
4 students.
Demonstrate the use of Overriding method di i asses
Note: Attach the code at the end, isplay() using Super and Sub
Viaharashira State Board of Technical EducationMe
gramming (22412)
AS 9 py Baset
mot .
on ee phy dyspl) {
j PSY PorenL chss”),
css Mychild
. entep
public yord Sep Oe My Bose {
So-eC "Chil closs";
$ oe es \oId main(String SCI) £
cin } ;
ae eW MyChildl);
j
NIL. Practical Related Questions
Note: Below given are few sample questions for reference. Teacher must design ©
more such questions so as to ensure the achievement of identified CO.
1. State the difference between method overloading and method overriding.
2. Method Overriding is an example of..... (Compile Time
Polymorphism/Run Time Polymorphism)
3. Write the rules of method overriding.
4 Write the use of super keyword in method overriding.
(Space for answer)
Overteline
EWo
with heart
classes
We
hinshig Sis Doand of Technical Education /Java Programmi
gramming (22412)
Sine Board of Technical Edveation
%
Maharastraaml Exercise:
1, Develop a program to display the rate of interest of banks by method
overriding method.
2, Write the output of the following:
class MyBaseClass
protected void dispQ,
{
System.out printin("Parent class method");
class MyChildClass extends MyBaseClass
‘ public void disp()
: System.out printIn("Child class method");
public static void main (String args[])
MyChildClass obj = new MyChildClass(;
3. poser to extend ‘dog’ from ‘animal’ to override ‘move( )’ method
using super keyword.
(Space for answer)
re
“shiva State Board of Technical Education
»jement multiple inheritance, ii implemened wy,
Ba
rectly ipl
Java does not ret im interfaces.
secondary inheritance path
[a
ra]
5 rs
(4) Sale inbeitence (Hliarcical inheritance
te]
(@)Alutevetestance (Maile intentace
Fig. 6 Forms of Inheritance
Defining a subclass:
Class subclassname extends superclassname
{
variables declaration;
methods declaration;
}
The keyword extends indicates that the i tei
aac Properties of the superclassname are ©
VIII. Resources required(Additional)
Nil
IX. Resources used (Additional)
Sr. Name of
No.| Resource Broad Specification Qty
TT ec ‘5
8 fhe YD -
2
S/n VS Cole ; a
‘Maharashtra State Board of Technical Educatisppoernes cna
yes
program Code: Teacher must assign a separate program statement to group of 3-
+ students.
Write a program to implement single and multilevel inheritance.
Note: Attach the code at the end.
inLevface AL
public void disCint num);
inlafoce Bl '
public vold dts jp numy
Class Mult Implements A,B f
public word oS Cink! mum) C
Se. pC From Ary num),
puolic ' yor arse int num7{
4 S-0.9 UT From pil Anum);
J
cass St extends Mul f- : :
Ye static void malin (String ST {
Mut ml = new Mutt); ”
mil-dis (0) ) :
ro) disp [20) ;
XL Result (Output of Code):
ctical Related Qu
htra State Board of Technical Education“4
Java Programming (22412)
tions for reference. Teacher
to ensure the achievement of identified Co, MUSE ¢,
eeegiuiees ) ei
tiple inheritance. lm
Note: Below given are few sample ques!
more such questions 50 as
1. Justify: Java does not support mu
2. Specify the conditions when the super keyword can be used.
1s and methods.
3. Waite the importance of final variable
ads to be satisfied while using the abstrag
classe
4. Specify the conditions which net
(Space for answer)
Tharcahira State Board of Technical Education iEe
pee
um Ererise
Dessiop a program to imple
evelop a program to calcul
of single inheritance (Assume suitab!
ment the multilevel inheritance.
Tate the room area and volume to illustrate the concept
je data wherever necessary). "
(Space for answer)
fo
|
3
bh "ste Board of Technical Education izMaharashtra State Board of Technical Education
6
————— re
awva Pro
2. Multiple Interfax
2412)
interface ItemConstants
intid-100;
string name="ABC"s
)
interface ItemMethods
void display( );
}
interface Item extends ItemConstants, ItemMethods
{
}
3, Implementing Interfaces:
Interfaces are used like superclasses whose features/properties are inherited by
classes.
Itis mandatory to define a class that inherits the given interface,
class classname Implements interfacename
body of classname
}
‘The class classname “implements” the interface interfacename,
class classname extends superclass implements interface, interface2,....
{
body of classname
}
VIIL. Resources required (Additional)
Nil
IX. _ Resources used (Additional)
Se] Name of ia Femarhs
No. Lesource ad Specifieation y y)
TT pe on Qty (ifany)
AIT SSI 6B ’ —
3 \SCode : -
Naharashira State Hoard of Technical Wiscatgy
ES eee ar
ng (22412)
a
program Code: Teacher must assig
% 4 students.
Demonstrate the use of interfaces to j ple inher
Note: Attach the code at the as “plement ibe cnsept af molpeinheianes
taterface Printable f
vord ern bey
a @ separate program statement to group of 3-
interface Show gblef
Void showl;
clogs NT itaglerments PrinLoble Showable
PWN veld prinlO
5.0. ptr Hell’;
pute void show) {
4 S-0.P 0" Welcome)
pubWe stable voll mafnCede
. 1
AZ obj > hew ATO; ae
Obs - prINLO; .
obj . Show);
4 ‘
Y,
Ia
“a State Board of Technical Education "Java Programming (22412)
XI. Result (Output of Code): !
XII. Practical Related Questions .
Note: Below given are few sample questions for reference. Teacher, must dey
more such questions so as to ensure the achievement of identified CO.
1. Differentiate between Class and Interface.
2. Write similarities between interfaces and classes.
3, Write advantages of interfaces.
4. Will this code compile successfully?(Assume Suitable Class)
public interface FamousLine
en
void ShowLine( )
{ Fi
System.out.printin(“Show Line”);
}
(Space for answer)
‘Maharashtra State Board of Technical Ea, on————,] Educationyr
ing (22412)
Se a er a ee
3Sfe EE gh eet eres
cessing» Package y
: ‘kage can be i 7
eos aystem package can be accessed ether ;
aoe "shortcut approach through the impor eae qualified class name or
syntaxt
ort ee C package? package3) classname;
Hagel is the name of the outer package, package? i
jsinside the packagel. package, package? is the name of the package that
package hierarchy consists of any number of packages, Finally the explicit classname
is specified.
Example:
import firstPackage secondPackage MyClass; fully qualified class name
OR : ?
import packagename.*;
import firstPackage.*; /shorteut approach
Vl, Resources required(Additional)
Nil
IL Resourees used (Additional)
Nameot | proadSpeciteation | QW Remis
iS
PC FIST CB 1
[ [aan | ape Volokh - |.
Program Code: Teacher must assign a separate Program statement to group of 3-
4 students.
Write a program to implement user
package and importing the same.
Note: Attach the code at the end.
rock cg e myfackage
Public css Compare {
Int Int
. Cornparelint oyindmn {
niin
nvzm,
defined packages in terms of,creating a new
43
\SiaroreaarJava Prog Te nee) gel marl)
AueCiigle ce Sa eee
Sop ("Mow fs ni);
get
Dero is” and);
)
XI. Result (Output of Cod
ss
XII. Practical Related Questions
Note: Below given are few sample questions for reference. Teacher must design
Tee Such questions so as o ensure the achievement of identified CO.
1. Name some of java packages,
2. Can we import same class/package twice? Will the JVM load the package twice at
mun time?
3. Write fully qualified and shortcut class namin
8 approach with examples.
(Space for answer)
Maharashtra State Board of Technical Education
ad
ee cerermmmmmmmmmmrring (22412)
peeJava Programming (22412)
‘XII. Exercise (Any two)
1. The code uses the class defined below. Class Importclass is not definey
: giving any errors?
folder. Will the code run without
import circle NewCircle;
class ImportClass
{
public static void main(String ares{ })
ney
circle NewCircle no-new circle NewCircle( );
System out printin(“Hello Java”);
}
}
. Define a package named mylnstitute include class named as department with coe
method to display the staff of that department. Develop a program to impor si,
package in a java application and call the method defined in the package.
3. Develop a program which consists of the package named let_me_calculate wit
class named calculator and a method named add to add two integer numbers,
Import let_me_calculate peckage in another program (class named Demo) to ei3
two numbers.
(Space for answer)
ent
ain}. plan ies .
Maharashtra State Board of Technical Educa,
Teoss 042 ‘eq
a
y
gu Resources required (Additional)
vt
Nil
pesources used (Additional)
‘| Name of Resource Broad §| ce Remarks
é| mad Specification | Qty an
1 | Computer Systém 5
[ity specifications BISI2 GB ' >
[ ht twore TPES Ale ae
x, Program Code: Teacher must assign a separate program statement to group of 3-
4 students.
Develop a simple real-life application program to illustrate the use of multithreads.
Note: Attach the code at the end,
public verdad wnt) {
uy L | (Th J” Th o!
Sy6 tem.oul-pintin read | + 1 Pree «
9 cuyrent Thread ()-getTd ()+ ‘rs Tung’
Jeutch Ui xception e) 4
5 op" Exception cought!)
5 E
3
purlie class Multi thread £
Public sh&tic void main(String slyf
inh nV)
fo Cie Oyvany fat,
Mul b’Lhyeading Dero obj'= new
Mul bithread tng Demol)s
oby-5 tart
Ma 107
“shtra Slate Board of Technical EducationJava Programming (22412)
XI. Result (Output of Cod
XII. Practical Related Questions Fos
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1, Isit possible to start a thread twice?
2. Can we call the run() method instead of start()?
3. Differentiate between notify( ) and notifyAll( )?
4. Explain the use of keyword synchronized.
(Space for answer)
Maharashtra State Board of Technical PducationJava Programming (22412)
| _ Maharashua State Board of Technical Educator
i ira State Board of Teo ion waN
Java Programming (22412)
XI. Exercise: rocesses.
1, Implement multithreading to perform Se erCe threads while settin
2. The code give below calls the run( ) methowt t, correct the code, 8 Gee
Priority. Will this code compile successfully? If no °
* class tl extends Thread
{
public void run( )
{ . .
System out printin(“This is Threadl class”);
}
i}
Class t2 extends Thread
{
Public void run()
{
System.out printla(“This is Thread2 class”);
}
}
public class ThreadP
{
Public static void main(String argsf ])
t1 t-new tl();
2 tr=new 12();
tsetPriority(Thread. MIN_PRIORITY);
tt setPriority(Thread MIN_PRIORITY);
tLnun();
‘2.run();}
}
3. Create three threads and run these threads according to set priority.
(Space for answer)
‘Maharashtra State Board of Technical Education if
idjava Programming (22412)
aring (22412)
unm |
Fig. 12 Exception Handling Mechanism
cqgon Simple ry, catch and finally statement
7
statement; generates an exception
‘gch(Exception-type’€)
i
"statement; Iiprocesses the exception
fay sssssssnes} optional
Finally Statement:- ;
finally statement handles an exception that is not caught by any of the earlier catch
statements. ted within a try block
Itis used to handle any exception generated within 4
Itis writen immediately after the try block or after the last catch block.
MM. Resources required(Additional)
Nil
Resources used (Additional) Reniark
Xi) Name of Broad Specification Qy (fany)
“ Resource 7 ;
. a
pL PS § (62 6B -
_ 5A yor 8? -
Program Code: Teacher must assign ® separate program statement to group of 3-
$stua
nt catch and finally block.
15Java Programming (22412)
(Space for answer)
XL. Result (Output of Code):
Maharashtra State Board of Technical Education 16
4java Programming (22412) a:
XU. Practical Related Questions
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
~ How exception is thrown by main method?
. Differentiate between error and exception in java.
. Can we throw exception manually? Hlustrate with sample program.
. Explain the use of finally block?
Bene
(Space for answer)
17
‘Maharashtra State Hoard of Technical Iiducation iJava Programming (22412)
1. The program calculates sum of two numbers inputted as command-line arguments.
When will it give an exception?
class excep
public static void main(Sting args[ ])
{
°
int n=Integer.parseInt(args[0]);
int nl=Integer.parseInt(args[1]);
int n2=n+nl;
System.out-printIn(“Sum is:”n2);
}
catch(NumberFormatException ex)
{
System.out.println(ex);
}
finally
{
; System outprintin(“You inputted a correct integer number”);
}
}
2. Develop a program to accept a password from the user and throw “Authentication
Failure” exception if the password is incorrect,
3. Write the exception thrown by the following code block?
Integer{][] ints = { { 1, 2,3},
{ {null }, { 7, 8,9} };
System.out.printin("valu
e=""+ ints[1]f1].intValueQ);
“Maharashtra State Board of Technical Education ftf
i
Java Programming (22412)
(Space for nnswor)Java Programming (22412)
where Throwable-instance must be an object of type Throwable or a subclass of
Throwable. er .
throws: is a keyword in java. Its is used to declare an exception Iti used witha
method signature. Multiple exceptions can be declared through throws.
Syntax: a3
type method name(parameters) throws exception list
. Resources required (Additional)
Nil
Resources used (Additional)
Sr amet Broad Specification Qty ‘ite
1 15 =
mile lhe G& i
Sf Jor 13> = -
Program Code: Teacher must assign a separate program statement to group of 3-
4 students.
Demonstrate use of throw and throws clause.
Note: Attach the code at the end.
Class Thowk £
Stole veld fun() {
LYVY {
Lye new Null Pot ~ ;
j “Pemot) ointer Exce pt ion
cateh ( Null Porn ten Exception e) 4
j ee en ht ™siode)
4
oe .
public sidtie wid man (String sCy)f
ch Exception e)f
1 S-0 pl" Caught sp, man");
‘State Board of Te Education
122ai. 7
Java Programming (22412)
XI. Result (Output of Code):
XI. Practical Related Questions i
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. Differentiate between throw and throws clause.
2. In which situation the throws clause is used?
3. Write the simple program for throwing our own exceptions.
(Space for answer)
BBG arse
“Maharashtra State Board of Technical Education imps PE SHI
(Space fic amseex)
4 We
th . 2a4
Zep [i Moickes!
: St
ENS Ee
_ throw nels Sia rng l
Sines OE elt
Bi 8 5
Mikarasizra State Board of Technical Education 1sJava Programming (22412)
2. By Java appletviewer tool ae a
Through appletviewer tool, only applet ou - =
The panei is not a full-fledged web browser and therefore it ignores all of
the HTML tags except the part pertaining to the running of the applet.
To run the applet:
appletviewer HelloJava.html
Applet Viewer : HelloJava.class
appletloader.started
Fig.15. Output of HelloJava applet by using appletviewer
VIII. Resources required(Additional)
Nil
x. Resources used (Additional)
Sr.| Name of -
No. Resource Broad Specification Qty ay
Tl pe 9 ;
§ssi2 =
slf VS Cede
X. Program Code: rene
st assign a separate pro; 7
4 students. Program statement to group of 3:
Create two applets by using different ways in java.ja Programming (22412)
a ~E gave. ae ple E.Applet,
MPT asa. awh Graphics ; pie
7
| .
ie OSF Seeds tpi
teage-€ pain E(ropnics 9) f
26m String( Welcome, \50, 150),
ee
XI. Practical Related Questions
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. Differentiate between init( ) and start( methods. a “
2. Explain use of start( ) and stop( ) method in applet life cycle?
3. The method paint( ) belongs to which class?
(Space for answer)XUN Exercise:
E. Develon abasic empleo disp
to display “Weleom a
2. Develo a progres to implement all eaeere Pas of Applet”,
2, Deveig a program wsing cote loops i plac
(Space for answer)
Unbaresstie Wate Word Technical Vacation
132Java Progeanoming (22412)
Maharashira State Hoard of Technical FducationpvaProgromming (22412)
wate
Vil. Resources required (Additional)
a
1X. Resources used (Additional)
[Sr] Nameof ae
Ne. | Resouree | Broad Specification | Qty cant
1 pe 1 :
&IS 1266 \
2
of V8 Code ~ -
Program Code: Teacher must assign a separate program statement to group of 3-
4 students.
Write a program to implement an applet to draw basic animated shapes.
Note: Attach the code at the end.
rn port jova.aw b *,
import saver, gpplet-*)
‘closs Shapes extends Applet {
public i cere a)t
eLEont Lhew Font (“Campy iy
nen is); Oba toy", Font.
9: draw String ("DIFE. Shope. ») ,
5 drow Linet6, 20,50, ¢¢),° 215/15);
5 Srelnans Reet l 10,78, 40, 40):
7
XI. Result (Output of Code):
v 137
Mahara
‘tra State Board of Technical EducationJava Programming (22412)
XII. Practical Related Questions
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. Differentiate between executing the applet with appletviewer and HTML file,
2. Explain methods required to draw different shapes with different colors?
3. Differentiate between setforeground( ) and setColor( ) methods.
4. Differentiate between applets and applications.
(Space for answer) <
is o b
Qd. EGR nllLeay Ls! ol i :
nor way related to bl going be be drownet
ps teaming (22412)
XIII. Exercise (Any two)
1. Develop a program to draw a polygon.
2. Develop an applet for drawing a human face.
3. Write the output of the program.
import java.awt.*;
import java.applet.*;
”
*/
public class Arcs extends Applet
public void paint(Graphics g)
{
g.drawAro(10,40,70,70,0,75);
g.fillArc(100,40,70,70,0,75);
g.drawArc(10,100,70,80,0,175);
g.fillArc(100,100,70,90,0,270);
g.drawA.re(200,80,80,80,0,180); i
(Space for answer)
“soba State Board of Technical EducationJava Programming (22412)
XIV. References/ Suggestions for
1. https://www.javatpoint.com/
2. hitps://javaproglang. blogspot.com:
programming. htmli!. WOsRDdlzbI
3. Programming with Java-A-Primer by E Balagurusamy
r Further Reading
2014/03/java-graphics-
‘Mabarashira State Board of Technical Education 70Tea on amon ieee ea
pa Programming 22412)
xv. Assessment Scheme
Performance Indicators ‘Weightage
Process related (35 Marks) 70%
1. | Logic formation 30%
2. | Debugging ability 30%
3. | Follow ethical practices 10%
Product related (15 Marks) 30%
4, | Expected output 10%
t 5. | Timely Submission 10%
| 6. | Answer to sample questions 10%
| Total (50 Marks) 100%
List of Students /Team Members
1
Dated signature of
| Marks Obtained Teacher
|
| roe Lone Rencias) Total (50)
a> 1S XS Zz
5 Craw hrc (%50, 170735, 10, 0,780),
9 -draw Line (290, 965,% 16,275),
3:drom Line (240,265,240 1278);
3. drow Are ( 20, 275, 30,10) 6 ,-160),
9: dvaw A 175,200, 100 » SO, 0, -'86);
3
Ta
Miaharashira State Board of Technical Edveation
SeON
syatrpamsing 22412)
i. Minimum Theoretical Background
‘A java applet draws graphical image inside the space using the coordinate system. To
draw different shapes, appropriate graphics method with proper syntax is required.
vill. Resources required (Additional)
Nil
Ix. Resources used (Additional)
Sr. ‘Name of
No.| _Resouree | Broad Specification Qty
1
Remarks
(if any)
Soflnene | EDR eS ' ~
Program Code: Teacher must assign a separate program statement to group of 3-
4 students.
Demonstrate the use of basic applet, which includes different shapes like cone, cube,
cylinders etc.
Note: Attach the code at the end,
impenb jovetapple b.*,
import jove. aw b *;
closs Geo extends Applet
public vorol pent CQraphit s 3)f
35° +t Color ( Color GREEN);
3 hawLine (20,20, 100,20) >
3 drow Ree t( 20, 50,80549)'
4 SetColor Cocky RED)!
g Aro Oval(20 , '60 160, 100);
5
I#tapplet cocle >" Ger.clags” wid th >306
height = 90 7
dlapplet?
*/
rs 13
“sshtra State Board of Technical Education
RaeJava Programming (22412)
XL
Result (Output of Code):
Practical Related Questions
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. Which of these methods is a part of Abstract Window Toolkit (AWT)?
a) display() b) paint() ©) drawstring( ) d) none of the above
Ans
Ss.
2. Enlist the methods required to draw cone/cylinder.
3. Explain the method with syntax to draw circle.
4. Differentiate Applet and application.
(Space for answer)
Maharashtra State Board of Technical Education rey
ttlee 4
pa Progamming (22412)
1. Write output of the program.
*
+
import java.applet.Applet;
import java.awt.Color;
import java.awt.Graphics;
public class SetBackgroundColorExample extends Applet
public void paint(Graphics g){
*
* Set background color of an applet using
* void setBackground(Color c) method.
*/
setBackground(Color.red);
}
}
2. Develop a program to draw any 2 of the following shapes:
a. Cone
Maha
‘ashtra State Board of Technical Education ieJava Programming (22412)
b. Cylinder
©. Cube ,
3. Develop a program to draw any one of the following:
1a, Square Inside a circle
b. Cirele inside a square
(Space for answer)
a
‘Maharashtra State Board of Technical Education, ieJava Programming (22412)
xIV. Toe Suggestions for Further Reading
https://www javatpoint.com/
i https://javaproglang blogspot, com/2014/03 /java-graphics-
programming html#. WOsRDdl2bIU
._https://www java-examples.com/set-status-message-applet-window-example
4. Programming with Java-A Primer by E Balagurusamy
XV. Assessment Scheme
Performance Indicators Weightage
Process related (35 Marks) 70%
1. Logic formation 30%
2. | Debugging ability 30%
3. Follow ethical practices 10%
Product related (15 Marks) 30%
4. _] Expected output 10%
5. Timely Submission 10%
6. Answer to sample questions 10%
Total (50 Marks) 100%
List of Students Team Members
1.
sey
Dated signature of
Teacher
Process Product Related
Related (35) (15) Total (50) Ce
33 | Ab :
Marks Obtained
147
Mahan
“sarashtra State Board of Technical EducationJava Programming (22412)
IX. Resources used
Remarks
a Lea Broad Specification Qty afany)
T [Compuer| iS : i.
o pals S/arreG ep
eftLwaie | TDK 18> is =
X. Program Code: Teacher must assign a separate program statement to group of 3-
4 students.
Demonstrate the use of stream classes for reading and writing bytes/characters.
Note: Attach the code at the end.
Import jane. jo ey
class Toso {|
public static vord mon C Stung sj) Minow
ToEsception C
File Ff =hew Erie l" Bc /mytxd”),
Filelnplstieim f15 ~new File Tip st-
vem ily
bytes Jpty= new pytelOnt) frie. ();
pis recdl by); engl
File out = pew File ("PD vsmy.ixt'y
File Outpul Stream 65 = phew fF :
Stream lout); ew Nheut put
© katte Chytes);
Os/ flusin);
S¥-pl Success Fully ¥eusw Leen "')j
‘
j
‘Maharashtra State Board of Technical Education i
_Java Programming (22412)
XI. Result (Output of Code):
Xl. Practical Related Questions
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
~ Enlist java stream classes, file operations.
- Explain InputStream and OutputStream classes along with methods.
. Explain Reader and Writer stream classes.
. Find the compile-time error in the program given below.
import java.io.*;
class FileOutput
{
RES
public static void main (String args{])
{
FileOutputStream out;
PrintStream p;
‘ Out=new FileOutputStream( );
p=new PrintStream(out);
poprintln(“This is written to a file”);
p.close( );
catch(Exception e)
System.err.println(‘“Error writing to a file);
} (Space for answer)I. Develop a program to copy charac
2. Develop a program to write by
3. Develop program to dopey the coment of i Supplied as command line
‘Maharashira State Board of Technical Education aamming (22412)
a Pte
(Space for answer)
chaieal Bdueat
153
WMaharashtra State Board of Tet-—linport Jove owio
public class Byte {
—-eulblic etotic vo rol
——_i \
roe | main 4 xing at
3 Laing abr
Lay
{
"DpP prise;
FileCuleulSixeam fos = pew file ~
|
Oubpsl Stream (3br);
String Styt = “Ramon? )
fo5 wottbe Cs ExC- gel Bytes ();
fo cle sell,
5 Da £0 wivtben into frle pty
1c okch (FileNot Founo) Pxcep bon ex)
1
\
Soo CBile pot found!” tex)
i
fateh Lofxception
foe)
7 Sol" Toexception 4 toe lyfoto 7 7 (a
SM import fowa. 103
foe Copy .
public stob'c sord moun { Siting sty
{
Lay
{
Ele Input Stream fy= new File ~
Lnoy f Strevm Chew EvjeCs toy);
Ink 0; :
while CCfefy-eod())) =-7)
oe
Sep lkchar) i), :
+ Frclo se();
° Toy IndexOut Of Bounds Bx ex.
coche Bring mds
x Soel" C:NUsers\ Desk bop \\ file) f
patch U9 ception ex)
it
Sep C"Eyle does hot
f ; ;
5 direc bay"); es iien