0 ratings0% found this document useful (0 votes) 141 views37 pagesJava Programming Manual 1 To 12 Ans
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
i ‘Software {jak1.8.0 or above.
TX. Resourees used
fame of Remarks
i SNe (pera Broad Specification ay (tan,
1 ‘Computer 13-15) RAM As pew
i; System Apa andy on —41—
with bron e
: specifications on ata P
; zag | soe windows lo | size | ——tt7
3 [Am her 5
; ae jek 1-8-0 lees
4 X. Practical Related Questions
Na Below given are few sample questions for reference. Teacher must design
snore such questions so as to ensure the achievement of identified CO.
wy Write installation directory path of your directory?
2. Write value of path environment variable?
3, List folders ereated after instalation.
4, Main method is declared as stati. Justify.
5.
Program is named with class containing main method. Justify
f {Space for answer)
dixecken:
Files javen. ™
’ ‘Maharashira State Board of Technieal Education
321..canf.
Finclude.
exeaching.
_texoninace.
‘Maharashia Siate Board of Technical Educationyram Core: Teach
a Rao class Leapyear Example
lool oil (yeo” vy. Yoo=
2020:
int year
hq == O)RE(yeat
if (CC yea¥
“
system. ovt. printin ("Leap dear
3
oe i
else §
System: ovt -println
5
("EE is a tomnmon yea”
5
tpuk t-
Ovtput * Leap Jeav
XI. Result (Output of Code):
TTR Sal DE ore A AAEM,
else... stakernsnts...
XI, Practical Related Questions .
Nate: Below given are few sample questions for reference. Teacher must design
‘more such questions so as fo ensure the achievement of identified CO.
1. List operators used in if conditional statement,
2, In if-else construct which part will be executed if condition is true.
3, State the condition when the else part will be executed with example.
‘haratia Ste Board of Techical Eaveaton212 _Conditvienal.....OR...eperabar.
SZ nncdermaxy. operate.
—pCeonditied
11. Skavernent..
else.
>
’ ee
> Ans... Syntar..fax. ip.else...skakement...l'
‘ au
’
,
’
,
,
y oo
’ $0){
System.outprintla("number is greater than 50");
}
}
}
1 5
2, | class IfStatement { Number is
public static void main(String{] args) { Posikve.
int number = 10;
if (aumber > 0) { Ris stokement
Systemout printhn("Numberis positive." | 5 ios us.
} is alway
‘System.out.printIn("This statement is always executed +
executed");
}
L
2. Write a program to make the use of logical operators.
3. Write a program to check no is even or odd.
Seace ‘Answer)
J close... Lagital...operas ee
4
_public..stadfc. usta. main. Staing..argst1)
whooleom.... Resulk..\.
Cnurmbecr.a.z..nvmbst2..).Caumber..2z.nunober >
~Axgemmce paintln.Creault):
reasabk. Commer. ann lhen. 2)s
out... palmtl,|
‘Maharashtra State Board of Technical Education 3Class..EvenOdel
{ oe
uiblic..skakfc...vetd...main..C. Staiing..angs..L.4).
P gg
‘Maharastra State Board of Technical Educationava oromming (22412)
case value?
11 Statements
break; // break is optional
case valueN :
1/ Statements
break; break is optional
default:
1/ Statements
2. Conditional if ((ernary operator):
Syntax:
result = testStatement ? valuel : value2;
VIII. Resources required (Additional)
Nil
IX. Resources used (Additional)
Sr.| Nameof | i ficati a Remarks
Re] RAMEE | Broad specification Quantity ‘itany)
T [Computer | Computer [73-15] [As pe batch Fon all
Specificakiog RAH aa B siae exferiments|
2 [openaking
Foysrens Windows 40 a ee
X. Program Code: Teacher must assign a separate program statement to group of 3-
4 students,
Write any program using switch-case statement.
class Switch Statement : “er %
haute stake void main (Stating args! ;
indie ds j , .
suit ch (1D output:
cose O: System. ouk.porintln (" Ero’):
break ;
case li System. out println Cone");
bowak +
ae ae System oul. priatln (TO)
ak Syptern- out. pouintle ("DEFAULT
‘Maharashira State Boand of Technical Educ(Outpt of Cote? , :
ve develaped priognarnd le (ern natarale. Mae
alkverhents and. conditional. 1
Reel
\
ot bed came
ions
few sample questions for reference, Teacher must tesla
rons so as to ensure the achievement of idemified
not written fora ease in switeh ease?
ed?
itch expression?
eui_chasach...tak..waap.
enatlax, shonk ond Int
aharasbira Sate Board of Technical EducationA) dnawour
clars..0 porater.
Stouing ange ci)
pute ha kic..wreid mnain C
i cu Fi Boat
puak.pasibirs:
eahct i.
oa saad Sai ented)
stow
coe e athe eo "pe
S&ypleroe.
19
‘Maharastra Sate Board of Technical EdueationCode
peer
fet ura?
ew
Be een can rit
fea, at pin "Ca8e2 Value is:
3
fem.out piatln(
efit:
System out pit
ens Pream{
reptc “Satie woid main(String] ares) {
int value = 100:
switch (value) {
ease 100:
System outpritin(tue);
case 100:
system. outprinin( true),
case: Value is: "#num);
"+num);
case}: Value is: "¢num);
Default: Value is: "+num);
Beroritinipal |
Defeat Vohus Us: 2 |
4, Wait any program to check switch-case statement using character datatype.
(Space for Answer)
‘Maharashtra State Board of Techical Education
20
- ann ann a 0 0 0 RAAAAAADAGbreak...
Case..!.b!
minkln€.*.CASE.2.2%
sulspsintin (case 3
‘Maharshia Sate Board of Techeal Education 2AN, Resources used (Additional)
Name of Broad § Remarks
|__Resouree = “(ifany) ;
1 Komputer |Compucker Fox all
syetem RAN - 248. eotpoamants
loperaking rwindows 10
Program Code: Teacher must assign a separate program statement to group of 3-
xX
4 students.
Develop a program to print command Fine argument using for loop.
class Command Line Argument
pit stakic void main (String angs C3)
split osidangs: length : +4)
spain agro):
‘
S
Outpt g
lo
Bo
BO
XI. Result (Output of Code):
‘Maharashira State Board of Technical Educationa) Answer
NO we cannok woite
: nil a fom Lop. without inka: eatie
u ay a for. lemp. usithout tnhalinalien. an ‘
crutot...sill, occurs tnd calsing...ad....nok..o . hed
sdotement J epee
3] Anaser=
“he. for. omp.th .
dos. (ink. j= +} NOL FALE D aco
XII Exereis
1. Write any program wing
2. Write any progam [0
increment/decrement
if condition with for loop.
display pyramids of stars/pattems using
(Space for Answer)
26
‘Maharashtra State Board of Techaial Elucationelse
for Cink jd ys.edh4.
‘Maharashtra State Board of Technieal Education 27Ouantity Remarks
(ifany)
15] /As Per bate, For al A
8 size excperiener
2 [ofevatt aa — Site lex
papa Windows 10 | —1— in
{ FF wae, JARI TO
= -
m Code: Teacher must assign a Separate program statement to group of 3-
4 students,
Develop a program to use logical operators in do-while loop.
class logical
Public static void main (Storing CJ args)
{
int Pos
dot
Tot nomber 4-1, nombet 222 member 3= 3,
boolean Yesult:
Yesult = (number t> numberd || (number 2> nomber i).
System. out. printin (result);
result = (number 1> member 2) && (number 3 yaumnber |);
System. out. println(vesul¥);
Vtt+;
Juohile (ix = 8),
XL Result (Output of Code):
Maharashtra State Board of Technical Education
301 elated Questions
Relow given are few
jections so as to ensure the achieventt
xn.
more such ym
Ls
2. Iindo-avhile loop termination condition is ehecke
3. How many times dovhile loop will he executed
(Space for answer)
‘Maharashtra State Board of Technical Edueation
imple questions for
reference, Peachee mnust design
nt af tdenified CO.
itference between while ant do-while: Joop:
: Hersh eaaen lca rete (heginninglend)
dat
1 if condition is false?nnide
the do while loop
once:
Condition oy test expression is checked oF
We eccpression. ford. cshile.enust return.
Obhereai se... i:.vai ll ehroto Cornpile,..Hiene,. cern:
excuulton ab least
Vast -
* syntac: |. Flow, chart.
=o aor 4do while Loof 1
Astaternenks: kernents inside Loo?
cahile. (Boolean.exp")
XII Exercise: Ovtsicle do whi
1, Write Error/outpat of code in the given space.
Be Program Code Error/Output
class DoWhileBasies
{ fi
public static void main(String args{])
{
inta=1;
do
{ i
‘System.out printIn(a);
a=atl; /oraHt;
}
while(a<=10);,
9}
eee
&
ka
class Test {
public static void main(String) args) cuerpo .
while(true) { .
System,outprint(1);
2 do { .
System out prin(2);
) while (alse);
}
}
noolean
“Maharashtra State Board of Technical Education
aA AAA AAA
ana
a AAR AR AO eoJW.
4 Iip erunnebooK £0 Pao 1s/0vdo-whiler
eSpace for answer)
et Seeing. I. O0R)~Ville tng table ae THEO
ee | from fo
A Hy hn cnt eo fa, el
| at aig, Hoa, wd
yd omg, dla, double |
1 fine float, double
5 | oat double
vin. resources required (aaditional
Nil
ional)
Resourees used (Addi
IX.
Sr] Name of 7
No. |__Resource_| (irany)
| [computer iH [AS pet & 4
‘system pakeh size |exferined
loperaking
systern
[3 of +uare:
x. Program Code: Toad
4 students.
Develop a program o show the use of implicit typecasting.
class Limplict+ Tyfecasting
public stale veld main (string 298 ea)
int j = 1007
Longl = it
Floatp= Lo
system. ovt. print#in
System. ovt- println
Systern- out. printn C' Flo.
j
j
("Int valve 244) 2
(" Long value.” +L),
ak valve" +f)?
Matarashira State Board of Techaial Education 35)ape ns htt ork
Nb resute coutpt
erg, es NN ye, ,dewlo
of (ihe raph ll types
and. pay
er encore Hee
iene 0.
Ml me eh eatett one ont
hel aL a mf
ihe acliler
Sa ily
‘emit
1 accent ri ste
wwe naw
ent at 1
wotean datatype 8
1 ra
plcily casted
it tye castle
vat typer 10
two example oF Fini
wie
(space foranswe)
37
i
rir Sate Board of Techn
ott raphe” “ alinJoa Pope CL
sorority
pr cessed.
° J swinre
@.Ysed..1O....Compe be... pXO9 fF
vartables,..are cour ectly
Fanckfons
@..Used.do..tell. the camnpiley Ahovk
+o... convent: clerta tay PS : :
A Used..-0..dacuenent. Hb ef 2A. GAO shew wahak,
IE. XXL. going..te. aaunsnnannse nan
boe..saeerl
ANSI see
©..A.... boolean.
other... assigne
datatype--ca0
as..Poipli.cil
‘Maharashtra State Board of Technical Education
38Program Cole
s
" sin nincstinnl Te) |
»
»
S
»
p pubtic class Test
> public static void main(String(] 0"89) {
char ch ='c's
. int num = 88;
ch=num;
> }
, :
4, Write program impli typecast IOwer range data type to larger storage S78
> Dns. datatype.
ica class Lmplicit Eyre casting
D public static void main C7Sststing eq args)
> 7
> byte i = 60.
short j
dP intkey
) Long = k>
) Float m =Lé
» dovble nem,
j sore. i printinG Byte valve tae
. out. pri 0 :
| hc st Ein wanes
System. ovk println(" Lon part eee
| easyem ok println cw Hs are en iy
4 . ovk. printin(" double value’ en?
L
5
‘Maharashtra Sate Board of Technieal Education
39ni
AX. Reanorers ed (Adana
FRemarke
ST Ae cease neste | Pe
[So resource fas on |
compote [computer 13-15) AS Per. We
[Sets emg P| babe Are oe
7 loperati a neth 1—
Fpepereting | windows io | —!— 1
gt eoprware | 3d TT: eo :
x rogram Code: Teacher mast acelin separate PrOz™
Asem.
to show the use of explicit type eating
Develop a program
ea Explicit Type casting
| ae static Void main (string ergs C3)
byteb>
int ie sls
double d = 323:'42%
float f= 72-38 F2
char c= ‘G's
S (chon)i:
ystern.ovt. vintinC ie t4i"c a" ‘
ind? cre)
stem. ovt. println Cde"satic"
te Cint )2 ae
System-out. print CF a +E rem ays
aN
be (byte)d> oe
System. ovt printin(“de" +4 EMBED
4 XI. Result (Output of Code):
‘Maharastra Sate Board of Technical Education
ae RA AHons for peperence: tem
reves of HE
XM, Practleat Ri cjateat Qnestlons
ores Reto trend are fo S00
gmestiome sovas f 700
ple quest
uve the wel
more such
1 What is
3. What is differene sec pict ae expel type esti?
1. What is narrowing?
{Space for ane?
bk. ON pasricule’
n...0b}
Th anothet
means..catnag
nvertiog
Casting.me é
cdoype and aexalng Edina. Z.62
abject.Ayf. cnennnnncnnrnrne even
tuben..% dotakype Cind)Ls consexted
ne dh EA APE (double). he
ence
el
uciT TYPE CASTING -
pecastio: .
slit by, con i
[—Cenpltcit.t
is..pexfor
Aen
.Genopiler...om it
n.connten. 3c!
.casting
There. 9.2
.infiax.makion....1ess.
4
‘Maharashira State Board of Technical Edvcat
fom
ajal
ee
ANS — NARROWING s
a connection
athe... Svpet
during
Naarocain
jts..subcl assy
XI, Exer
such git vations: ; .
Navromwing. wider big ge™ primitive ty
J imilive. type. Halves vense !
et Jigs reperrence. da. APE xeFe
Pyrite Error/output of code in the given space.
Sr. No. Program Code Error/Output
7. | class Testt Output
public static void main(String] ares) { Output
= 00.04: Doble valve: 100-4)
lo ree Lona, valve: 100:04
Systemoutprintin("Double value "sds, [Tok value: 100
System out printin("Long value "+;
System out printin("Int value "+i
}
}
2, | class Test r
public static void main(String args{]) —{ Output .
byte b= 50; ;
b= yt} *2), 00
System.outprintin(b); i
}
}
‘Maharastra State Board of Tecval EdveatonJava ogening 2210)
«vi misting ast?
rare /v)- 0"
double d=
ain resll =" + Fests
double rest
sgystem.oulpr
Wate « program to convert variable of basic datatypes and shows result of explicit
typecasting:
(Space for Answer)
oo MOSS. Excplisit.cast 199,
rinthe.C
System. ole prindinCe. Long..walu
01k. puiatio. Shark...
outs. _println.C by Net
Maharashia State Board of Technical Education
a5Statements for initialize the data members,
)
Copy Constrnetor
Statements for initialize the data members,
VIL. Resources required(Additionaly
Nil
IX, Resources used (Additional)
Si ks (If any)
S| SoS! [ee eee aes
1 Compotey Competey[i3-16]| As per | Fox all .
System | RAH-2UB batlin sist exc periments
2 Opevoki Ni |
ene windows 10 |—n— | —I1——
Software dK 17-0 —u—_— || —— Mal
iW
ram Code: Teacher must assign a separate program statement to group of 3-
4 students.
Demonstrate use of at least two types of constructors.
class stodents 5 t
int ids
String names
int ages
wtudent 5Cinti, string 0) §
id=ic
Name = nb
stodent 5 Cint i. string 01 inte) ¢
\d=ie name =
void display c)
Jstem- out. display (idt+ "+ namet" +a,
ypoblic stotic void main (string EJaxgs) 5 ¢
Stodents sl= new students § (1. karan")!
Stodents s2 = mew stodents(222," Aryan")
S\. display cy,
$2- display o75
sagé=a.}
- - a
Maharashtra State Board of Technical Educationsna ogmming 2280
NI. Resull orntput of Comte):
: rn on
“rR as) ure AE devioped progtarm ot isapleraents?
Fee nskri6her “and rawdti ple Lansknuskot pene
wast design
“sr tated! Questions ‘
aaa pew sap questions for reference Teacher 1!
apidentified CO-
shievement
Practic
ce the acl
Notes Below 8
more such questo!
1. Docs constructor
fy the sit
specify the
How construct
NI
‘so as fo erst
(urn value?
when the defi
when the default
wat eriading ca be done?
lt consteuctor is provided by the system
defined in the class
constructor is xP
2
3.
4
(Space for answer)
Ans
UNG -A cE: user.
Yow...1aill.
sourcecode...
ca mnpliaki an.
Ans3 TE.n0:
“and..one...canskxwctor.
clienplisitly.. declares.
THis...CONSEAASEMN oak
The.compiley...cal
conskxacter...cel
Ftype:
itl nave no...const
nd... Ull,..body.:
‘Maharasliva State Board of Technical Edvcat
x te
al Education
ro)EEE eiendnieneeeaieneeeeee
avn ogra (22002)
. thod
Ans4 i].In Tavay.a constxvctot..48 just Vireo 0% ral
but. withonk,.rekora...by Pe Tk..can ahs.c.... Ae
he @
meket
like... Tava methods
Z].constxvckor overleading...an be...dane.... when
ig than,..one...censtxvetor Gout. .dipperck ok. Pee"
lish: sannngesennnnecnmet
3).cThey..are axvanged 1) AMO that..cach
ror 0S....0..diFFEr ene. tasks:.. .
CANE... differentiated. by
4) Nanety
nomiber.... oF. aa ca i
re
5
30
Maharashtra State Board of Technical Educationsavn fgsning 22102)
gn, Bxerelse! sae
1, Waite apatite we p
Outpt
Re Program Calle
chest 0
ith a .
bt te j
4 sos Main ( please Tepine
Iss Main
“nh ring atest) main enethod as
ic static O°!
publi state vod
{
Tuenew 10s
System out printing:
}
‘Modify the following Dr
sre used in the program:
class Point
2
int m_x™Y3
public Poimiint x ty)
pxas MYT
ince void main(String arssL))
Point pl = new Point0}
Point p= new Point(23)s
System. out printin(”
System.out
System.out print
}
}
3, Write a program to implement di
‘of complex numbers.
rintIn(“X"+p1.m_X)s
ey"+plm_y)s
sterent types of eonstructorsto perform addition
(Space for Answer)
‘Maharastiva State Board of Tecnieal Education|POS ce. cthis PROQTAM 0... pare oneheized..constrechey,
Ls. baving...ctwse “pasar fea 1S... LA. Ae paxacoe ber,
whisds,
¥
NIV, Roferences/ Suggestions for Further Reading
1. htips:/Avww-youtibe.com/vatch2v=Ir¥ ghXsoI
2. hups:/freevideoleetures.com/eourse/2513/java-programming/ 17
XV. Assessment Scheme
Performance Indicators Weightage
Process related (35 Marks) 10%
T_] Logic formation 30%
2 | Debugging ability 30%
Follow ethical practices 10%
Product related (15 Marks) 30%
Expected output 10%
Timely Submission 10%
6 | Answer to sample questions 10%
Total (60 Marks) 100%
List of Students /Team Members
2
Be
4
; ; ©] Dated signature’)
‘Marks Obtained of Teacher
Process Product
Related(@3s) | Related(is)
“Maharashtra State Board of TechniealBdeation SS SSSSS~S7
Java Progranening (2412)
X. Program Code: Teacher inust assign * separate program statement (0 group of 3-
5
>
>
>
D public static void main (string 79 cD
‘ Suing s = "INDIA" 2
Staing sl= “suray"?
) string $2 “ prana’*
Staings3 =~ TAVA":
storing s4 = “ Programming" =
System. out. printlo (chavacker ot endext 23 "+ s-charRt (29) =
Systern- ovt- printiol Compaxing both strings Mase company Te ts):
system ovt- printin(" After Concat t 4-52. concot (53002
system. out: printin ("checking equals coith case: s.equals(s))°
Sustern-out- printl nC’ checking & wals Ignoring case ?”+s2- equals Ignevt
4 Pree) daca 3 ‘g By
intl C* Checking Length
Jace Funckon :+si.neplace ("E
Systern oot +p’ ” 4-83. length es: Gay):
system. out. printinC’ Repl Peete)
System. out. printla (Converting te Lowey Case W452. Lower O02
en .ovt-printin C’ooverting te Upper Case: "46 4.te Upper COPE cD.
Syste
3
4
of Technical Education s
Maharashira State Boar
be.ven are fer
ch questions so as to ensure t
w sample questions for reference. Teacher must design
the achievement of identified CO.
more s
1. List different constructors of String class along with syntax
2. List different constructors of
3, State whether String is primitive
StringBuffer class along with syntax.
datatype or class in Java? State the package.
E. What is difference between == , equals() and compareTo() method?
(Space for answer)Vcompare.tio..|
MON. A DAN
es objects..Tf... of the. string...ere..\valves. an. a...
they...ove..1e Fer... Tp.all the, geet Eran tok.
- are te.the...of.beth. the. skxinad these.int
same....cbjeck.then.ome..came,....the nik, Poay..be...less.
ORV D E RE gen MORMIAS. ANSE... EAN.
‘XIII Exercise:
1. Write output of code in the given space.
No. Program Code
class String demo{ 7
Public static void main(String args[]) { .
char chars] = {'2',°); Pataae ee
String s = new String(chars);
System.out.printin(s);
}
‘class Output{
Public static void main(String args(]) { | Output :
String sl = “Hello I love Java”;
Fi String s2 = new String(s1); Folse true.
FE System.out printin(s1= s2) +074
sl.equals(s2));
}
OutputJava Programming (22412)
Tinieal Education 38
‘Maharashtra State Board of Tec