You are on page 1of 13

SESSION 2:

Ques 1,Defne a class Person containing Name, Age and Phone Number as
data members and ollo!ing methods"
1#set$erson%string n,int a,long $# &o initiali'e (alue o data member
according to gi(en argument"
2#sho!$erson%# &o sho! (alues o data members on the out$ut screen"
)rite a Program to sho! the use o methods o
Person class"
Ques 2, Defne a class Em$lo*ee containing Name, +asicSalar*, ,-A, DA and
.rossSalar* as data members and ollo!ing methods"
1#setem$lo*ee%string n,double bs# &o set the (alues o data members
according to gi(en arguments"
2#sho!em$lo*ee%# &o sho! em$lo*ee name rom basic salar*,,-A,DA /
.rossSalar*"
)rite a $rogram to sho! use o methods o em$lo*ee
class"
,-A0112 o +asicSalar*
DA0122 o +asicSalar*
Ques 3,)rite a $rogram to dis$la* A to 4 al$habets using AS5II (alues"
Ques6,)rite a $rogram to acce$t the height and radius o cone and
calculate the surace area and (olume o cone"
SESSION 3:
Ques 1,)rite a $rogram to fnd out the result o ollo!ing con(ersions
using casting techni7ues:
Int 289 to b*te
Double 323"162 to int
Double 323"162 to b*te

Ques 2, )rite a method multi$le that determines, or a $air o integers,
!hether the second integer is a multi$le o the frst" &he method should ta:e
t!o integer arguments and return true i the second is a multi$le o the frst
and alse other!ise"
Ques 3,)rite a $rogram to use di;erent ormats o t*$e casting and dis$la*
the con(erted one"
Ques 6,In$ut t!o double numbers and s!a$ their (alues !ith using third
(ariables"
SESSION 6:
Ques 1,)rite a $rogram to calculate the time ta:en or light to tra(el rom
sun to earth,i distance bet!een sun and earth is 181 million :ilometers and
s$eed o light is 2<<9<268= met>sec"
Ques 2,)rite a $rogram that tests !hether a ?oating@$oint number is 'ero or
not"
Ques 3,)rite a $rogram to chec: the di;erence bet!een $ost increment and
$re increament o$erators"
Ques 6,AShiting a o n bits let is e7ui(alent to multi$l*ing a !ith 2Bn"i no
o(er?o! occursA")rite a $rogram to chec: the (alidit* o abo(e statements"
SESSION 8:
Ques 1, Plan !hat test cases *ou !ould re7uire to test all the i>else $aths
in the sales commission $rogram" Ada$t the $rogram so that it can be used
or a number o em$lo*ees, and so that it !ill $rint out at the end the
number o em$lo*ees $aid at each o the three commission rates"
Ques 2, &he $o$ulation o a to!n is no! at 18111 and it is eC$anding at 82
$er *ear " )rite a $rogram to determine ho! man* *ears it !ill ta:e or the
$o$ulation to eCceed =8111"
Ques 3,)rite aProgram to fll trailing numbers b* DEF S*mbol"
Ques 6, 5alculate sum o n number o natural numbers"
SESSION G:
Ques 1, )rite a method to con(ert celcius to ahrenheit" 5all it
celsToFahr
An in$ut $arameter to the method is degrees celcius"
&he method should return the ahrenheit (alue in the
return statement"
Note the ormula :@ ahr 0 cels E <"1>8"1 H 32
Ques 2, Write a method to calculate a car allo!ance gi(en the si'e o the
engine and the miles tra(eled" &he rules are as or 71 $age l3@1= i"e"
engine si'e I0 18111 gi(e 21c $er mile
other!ise gi(e 31c $er mile"
&he method should ha(e 2 in$ut $arameters, engine si'e%int# ollo!ed b*
miles tra(eled %double#
&he method !ill return the (alue o the allo!ance%double# to the calling
module
&est *our method !ith the $ro(ided dri(er TestAllowance.java
Ques 3,)rite a $rogram to enter a month number o *ear 2112 and
dis$la* the number o da*s $resent in that month"
Ques 6,)rite a $rogram to calculate the sum o indi(idual digits o
entered numbers"
SESSION 9:
Ques 1, Imagine that the user enters 8 "!hen as:ed or the number o
students, and the ollo!ing mar:s : G8, =2, 36, 9= ,86 Jill in the contents o
an* (ariable or $art o the arra* as it is addressed in the code" Di(ide the
outline o stuKar:s belo! into the a$$ro$riate number o LslotsA %or
elements# Number the slots and fll in the contents o each slot as it is
addressed b* the code" Note also !hat is $rinted out on the screen and an*
in$ut b* the user"
i numStudents i
on screen
stuMarks
Ques 2, Insert the code to $rint out a table sho!ing student id and mar:s
Student id Kar:s
1 G8


Des: chec: *our code b* L!al:ing through itA !hile reerring to the arra*
holding the mar:s " )rite do!n the headings and ro!s o data as *ou !or:
through the rele(ant code"
Ques 3,In$ut name and mar:s o ten students and fnd out !ho is to$$er
among them"
Ques 6,Enter ten characters in arra* and sort them in descending order"
SESSION =:
Ques 1,)rite a code to $erorm addition,substraction and multi$lication o to
matriC,ha(ing dimension 3 C 6 and 2 C 3 res$ecti(el*"
Ques2,)rite a code to fnd out the trans$ose and diagonal sum o the a 2 C 2
matriC"
Ques 3, )rite a $rogram Arra*EC " Put headings to re$resent the arra* and
an* (ariables on $a$er" Jill in the contents as *ou !or: through the $rogram
and note !hat is $rinted out beside the a$$ro$riate line o code"
Ques 6,In$ut some string through command line arguement"Dis$la* the
length o String arra*"Also dis$la* the length o each String"
SESSION <:
Ques 1,Defne a class Point to store (alue o M / N co@ordinates containing
ollo!ing methods
1, setPoint%int C1,int *1# to initialise data members according to
gi(en arguement
2,sho!$oint%#&o sho! (alues o (alues o C / * co@ordinates on
out$ut screen"
3,fnd distane%int C1,int *1#to fnd distance bet!een t!o $oints
6,fnd distance%$oint $1#to fnd distance bet!een in(o:ing obOect and
gi(en $oint $1"
)rite a $rogram to sho! use o methods o $oint class"
Ques 2,Defne a clas s &ime containing hours,mins / secs as data members
/ ollo!ing methods"
1,set&ime%int h1,int m1,int s1#to initialise the (alues o data
members according to gi(en $arameters"
2,sho!time%#to sho! time in digital ormat
3,add%int h1,int m1,int s1#to add gi(en time !ith in(o:ing obOect and
return the resultant obOect"
6,add%time t#to add in(o:ing obOect !ith gi(en arguement t and
return the resultant obOect"
)rite a $rogram b* methods o &ime class"
Ques 3,)rite a Program to defne conditional constructor"
Ques 6,)rite a $rogram to declare global and local obOects !ith same
name"Acess members using both the obOects"
SESSION 11:
Ques 1,)rite a $rogram to defne a method in an interace"
Ques 2,Declare a class o (ehicle"Derri(ed classes are t!o@!heeler,three@
!heeler and our@!heeler"Dis$la* the $ro$erties o each t*$e o (ehicle using
member unction o class"
Ques 3,5reate a class countr*,state,cit* and (illage"Arrange these classes
in hierarcial manner"
Ques 6,)rite a $rogram to calculate energ* bill"-ead the starting and
ending meter reading"&he charges are as gi(en belo!:
No" O Pnits 5onsumed -ates in%-s"#
211@811 6"81
111@211 3"81
Qess than 111 2"81
SESSION 11:
Ques 1,)rite a $rogram to fnd the area o rectriangle and triangle "Pse
unction o(erloading"
Ques 2,)rite a $rogram to defne o(erloaded unction"In(o:e the
o(erloaded unction through another o(erloaded unction"
Ques 3,)rite a $rogram to o(erload member unction and dis$la*
string,int,?oat using o(erloaded unction"
Ques 6,)rite a $rogram to sho! use o this and su$er :e*!ords"
SESSION 12:
Ques 1,)rite a $rogram to calculate area o -ectangle and &riangle"Each o
these classes should o(erride area%# so that it returns the area o both
res$ecti(el*"
Ques 2, )rite a $rogram to dis$la* string in re(erse using recursion"
Ques 3,)rite a $rogram to generate fbonicci series using recursion !ith
member unction"
Ques 6,)rite a $rogram to count numbers bet!een 1 to 111, !hich are not
di(isible b* 2, 3,8"
SESSION 13:
Ques 1,Defne a class Person in a $ac:age containing name,age and $hone
no as data members and suitable methods")rite a main $rogram to sho!
use o methods o $erson class"
Ques 2,5reate a class calculator !ith methods or
addition,substraction,multi$lication and di(ision"5reate another class
Scientifc5alculator ha(ing methods o 5alculator class and its o!n methods
sin,cos and tan"5reate a class &ester in $ac:age test$ac: that !ill test the
Scientifc5alculator"
Ques 3,create a class Accesstest ha(ing member (ariables !ith acess
s$ecifers $ri(ate,$rotected and $ri(ate".i(e di;erent !a*s o accessing
those (ariables inside another class and subclass inside same $ac:age and
also in di;erent $ac:age"
Ques 6,!rite a $rogram to create Pser defned Pac:age"
SESSION 16:
Ques 1,)rite a $rogram to $rint number rom 1 to 11 ater e(er* 1 second"
Ques 2,)rite a $rogram to sho! di;erence bet!een Error and an ECce$tion
Ques 3, Is the ollo!ing code legalR
tr* S

T fnall* S

T
Ques 6,)hat eCce$tion t*$es can be caught b* the ollo!ing handlerR
catch %ECce$tion e# S

T
SESSION 18:
Ques 1,)rite a $rogram to generate all the $re defned ECce$tions"
Ques 2,5reate a Oa(acode code to sho! the im$lementation o tr* !ith fnall*
bloc:"
Ques 3,)rite a $rogram to acce$t 11 integers in an arra*"5hec: all numbers
in the arra*")hen a negati(e number is ound,thro! an ECce$tion"
Ques 6,)rite a $rogram to acce$t a string")hen a s$ace is
encountered,thro! an ECce$tion"
SESSION 1G:
Ques 1,)rite a $rogram to defne *our o!n eCce$tion,on basis o certain
(alidations"EC$licitl* thro! these eCce$tions and also them"
Ques 2, )rite a $rogram to create a user defned eCce$tion named
Qo!+alanceECce$tion that ma* be thro!n during a ban:ing
transaction%de$osit>!ithdra!#, i acc balance goes belo! -s 2111"
Session 19:
Ques 1, &he code tem$late or the 5ustomer class is gi(en belo!" Nou ha(e
to ensure that the age o a customer !ho bu*s a mobile o$ting or an
eCecuti(e $ac:age lies bet!een 21 and G1" 5reate an eCce$tion class to
$re(ent discre$ancies in data entr* or the age o a customer"
Ques 2,)rite a $rogram to create a user defned ECce$tion to chec: !hether
the gi(en no is negati(e or $ositi(e"
Ques 3,)rite code to create a user defned generali'ed eCce$tion"

SESSION 1=:
Ques 1,)rite a code to sho! Assertion Errors"
Ques 2,)rite a $rogram to Enable Assertions at -untime"
Ques 3,)rite a code to Disable the Enabled Assertions at -untime"
SESSION 21:
Ques 1,)rite a $rogram based on ollo!ing t*$e:
Kember inner class"
Qocal inner class"
Static inner class"
5om$ile the $rogram and then obser(e man* class fles are generated
!ith their naming con(ention"Ka:e a note o them"

Ques 2,5reate inner classes Innerone,Inner&!o inside a class Outer"InnerOne
eCtends a class +ase"+ase class,Outer class and InnerOne ha(e a common
integer feld (ar !ith (arious (alues")rite a code to acess (ar inside
InnerOne"5reate an instance o Inner&!o class outside the Outer class in
di;erent fles and access method accessKe%# defned in Outer class"
Ques 3,5reate a $rogram ha(ing nested class li:e this:
Inner1 !ill be inside Outer"
Inner2 !ill be inside Inner1"
Inner3 !ill be inside Inner2"
Ques 4, Design a class for a bank database. The database should support the following
operations:
depositing a certain amount into an account
withdrawing a certain amount from an account
looking up the current amount (i.e. the balance) in an account
transferring an amount from one account to another
SESSION 21:
Ques 1,)rite a Oa(a $rogram or sho!ing Anon*mous 5lasses"
Ques 2,)rite a $rogram or a class to be declared as static and non@static"
Ques 3, 5reate a ne! $rogram !ith a nested class named PrintFunc that eCtends
class Print" In addition to Oust $rinting the (alue, class PrintFunc should frst a$$l* a
Function obOect on the (alue" 5lass PrintFunc should ha(e a constructor that ta:es
an instance o Function t*$e as a $arameter" &he evaluate() method o class
PrintFunc should use the Function obOect on its argument" &he evaluate() method
should $rint and return the result" &he evaluate() method in su$erclass Print
should be used to $rint the (alue"
Ques 6, 5reate a class Half that im$lements Function" Ka:e the im$lementation o
the method evaluate() return the (alue obtained b* di(iding the int argument b* 2"
SESSION 22:
Ques 1,)rite a $rogram to create a child thread and eCecute the $rocess o
child thread !ith main thread concurrentl* b* using runnable interace"
Ques 2,)rite a $rogram to sho! the use o sus$end%# and resume%# method
o thread class"
Ques 3, Implement three classes: Storage, Counter, and Printer. The Storage class should
store an integer. The Counter class should create a thread that starts counting from (, !, ", # ...)
and stores each $alue in the Storage class. The Printer class should create a thread that keeps
reading the $alue in the Storage class and printing it.
%rite a program that creates an instance of the Storage class and sets up a Counter and a
Printer ob&ect to operate on it.
Ques 4, 'odif( the program from the pre$ious e)ercise to ensure that each number is printed
e)actl( once, b( adding suitable s(nchroni*ation
SESSION 23:
Ques 1,!rite a code or incor$orating date and time inormation"
Ques 2, )rite a code or the ser(ices o;ered b* di;erent dealers ha(e to
be ?ashed continuousl* on the customer details a$$let" &he ollo!ing
ser(ices should be ?ashed:

Dealer Name Ser(ice o;ered
5ellsot Inc Ser(ice charge ree or 1 *ear
S$ea:5or$ 112 discount on ne! mobile $hones
&al:)orld Inc +u* and !in $ri'es
SESSION 26U
Ques 1, )rite a $rogram to sho! ho! seriali'ation !or:s"
Ques 2, &he current date and time has to be dis$la*ed on the status bar o
the a$$let" )rite the code or the same using threads "
Ques 3, A chat utilit* is re7uired to sol(e 7ueries o the dealers online" &he
dealers should see a list o all the sales eCecuti(es online" A ser(er is re7uired or
this !ith the ollo!ing s$ecifcation:
Onl* (alid users !ith correct login should be ser(iced"
A dealer should recei(e messages mar:ed to that $articular dealer"
All dealer 7ueries and the solutions $ro(ided should be stored or
urther reerence"
SESSION 28:
Ques 1,)rite a $rogram to acce$t t!o numbers rom the user and $erorm
addition,substraction,multi$lication and di(ision o gi(en t!o numbers"

Ques 2, +reate a class named Pair, which aggregates two arbitrar( ob&ects. Implement the
equals() and hashCode() methods in such a wa( that a Pair ob&ect is identical to another Pair
ob&ect if, and onl( if, the pair of constituent ob&ects are identical. 'ake the toString()
implementation return the te)tual representation of both the constituent ob&ects in a Pair ob&ect.
,b&ects of the Pair class should be immutable.
Ques #,- palindrome is a te)t phrase that spells the same thing backward and forward. The word
redi$ider is a palindrome, since the word would spell the same e$en if the character se.uence
were re$ersed. %rite a program that takes a word as an argument and reports whether the word is
a palindrome.
SESSION 2G:
Ques 1,)rite a Program to read t!o strings through the
:e*board"5oncatenate the string and dis$la* the resultant string"
Ques 2,)rite a $rogram to in$ut t!o strings"One is the seC o
$erson%Kale>Jemale# and otheris name o $erson"Print the short name o
$erson $recede b* Kr>Kiss according to seC Kale>Jemale" Jor ECam$le
Enter *our seC:Jemale
Enter *our name:Surabhi Panda
Nour short name is:Kiss S"Panda
Ques 3,)rite a $rogram to re(erse the in$ut string using string methods"
Ques 6,)rite a $rogram that ta:es some string as in$ut through command
line $arameters"-e$lace L5entral +oard o Secondar* EducationA !ith
occurrences o L5+SEA in all o them"
SESSION 29:
Ques 1,5reate a $rogram that !ill concatenate arra* o string obOects and
stringbu;er obOects and the result !ill be stored in arra* o stringbu;er"In$ut
string arra* $ro(ided in command line",al o it !ill stored in string arra* and
rest o arguement stored in stringbu;er arra*"
Ques 2,5reate a stringbu;er class obOect !ith contentsANational Institute
o Sciences / &echnolog*A and a$$l* the ollo!ing methods o its o!n class:
Delete%8,18#U
A$$end%82#U
Insert%6,ADDA#U
-e(erse%#U
delete5harAt%length%#@2#U
Ques 3,)rite a class -e(5lass and o(erload a method as ollo!s:
String re(String%String s#U
Void re(String%String+u;er sb#U
&his re(String%# is a method that !ill orm a String out o all
strings su$$lied through command line arguments and re(erse it"
Ques 6,)rite a class Palindrome5lass and o(erload a method as ollo!s:
Int numPalString%String s#U
Int numPalString%String+u;er sb#U
&his numPalString%# is a method that !ill count the number
o $alindrome strings among the strings su$$lied through command line
arguments"
SESSION 2=:
Ques 1, 5reate an* collection and insert 8 strings through command line in a
random order and
$rint them in sorted orderR
Ques 2,
%rite a method that takes a string and returns the number of uni.ue characters in the string. It
is e)pected that a string with the same character se.uence ma( be passed se$eral times to the
method. /ince the counting operation can be time consuming, the method should cache the
results, so that when the method is gi$en a string pre$iousl( encountered, it will simpl(
retrie$e the stored result. 0se collections and maps where appropriate.
Ques #, %rite a program which creates a concordance of characters occurring in a string (i.e.,
which characters occur where in a string). 1ead the string from the command line.
SESSION 2<:
Ques 1,)rite a Program to sho! im$lementation o Set 5ollection"
Ques 2, )rite a Program to sho! im$lementation o ,ash set"
Ques 3, )rite a Program to sho! im$lementation o Arra* list"
Ques 6, )rite a Program to tra(erse a collection using iterator and list
iterator"
SESSION 31:
Ques 1, )rite a Program or ,ash Ka$"
Ques 2, )rite a Program to store Pser@defned classes in 5ollection
Ques 3, )rite a $rogram to sho! relation bet!een e7uals%# and hashcode%#"
SESSION 31:
Ques 1,)rite a $rogram to delete LData"teCtA fle rom hard dis:"
Ques 2, As a s$ecifcation o the unctionalit* re7uired, all users need to
login to the site to a(ail o the eatures $ro(ided" 5reate a login a$$let" &he
unctional s$ecifcation o the a$$let is as ollo!s:
&he a$$let should acce$t the customer name and $ass!ord"
&hese details should be recorded in a fle"
Ques 3,)rite a $rogram to create teCt editor"
Ques 6,)rite a Program to a$$end a fle"
SESSION 32:
Ques 1, 5reate a logon a$$lication or acce$ting the dealer details" &he
unctional s$ecifcations o the a$$lication are as ollo!s:
&he a$$lication should acce$t the dealer details such as name,
address, $hone number, and ser(ices o;ered b* the dealer"
&hese details should be recorded in a fle"
Ques 2, &he a$$let created in 6"P"2 is to be modifed into an a$$lication" &he
a$$lication should store the $erormance details o a customer care
eCecuti(e@name, grade, $erormance criteria, and rating@ in a fle" &he
a$$lication should also incor$orate the ollo!ing unctionalit*:
A button labeled as LSho! Perormance DetailsA needs to be added to
the $anel"
On clic:ing this button, the $erormance details o all customer care
eCecuti(es needs to be dis$la*ed in a teCt area control that is $laced in a
rame"
Ques 3,)rite a code to sho! ho! !e can seriali'e an obOect"
SESSION 33:
Ques 1, 5reate an a$$let dis$la*ing digital cloc:
Ques 2, 5reate a bouncing ball on an A$$let"
Ques 3,)rite a $rogram to dra! a house using a$$let"
SESSION 36:
Ques 1, )rite a $rogram to insert a image in an a$$let $rogram"
Ques 2, )rite a $rogram or an a$$lication that has been created to ca$ture
the details o dealers cannot be de$lo*ed on the local intranet o the
com$an*" 5hange the eCisting a$$lication to ma:e it )eb@based" A rame
!ith the dealer details entered, should be dis$la*ed !hen the a$$let is
closed"
Ques 3, )rite a $rogram so that the logo o the com$an* has to be dis$la*ed
on the a$$let that dis$la*s customer details"
SESSION 38:
Ques 1, )rite a $rogram so that )hene(er a ne! dealer Ooins a com$an*,
the details o the dealer such the dealer name, address, $hone number, and
ser(ices o;ered b* the dealer ha(e to be recorded" Nou need to create a user
interace or acce$ting the dealer details" &he unctional s$ecifcations o the
user interace are as ollo!s:
No restriction should be $ro(ided on the number o characters that
the address feld can hold"
&he interace should allo! multi$le ser(ices to be selected or a
dealer"
Ques 2, )rite a $rogram to generate G aces o a colour cube and these
aces must be dis$la*ed on O$anel"
Ques 3,)rite a $rogram that com$ounds interest continuousl* to a s$ecifed
$remium, rate, and number o *ears" Dis$la*s the total !or: u$ in the .PI
$anel in a tree orm"
Ques 6,Design the ollo!ing .ra$hical Interare using Oa(a"a!t
SESSION 3G:
Ques 1, Psing Qa*outs and e(ent handling, create the ollo!ing orm %use
hard coded (alues
Screen 1 @
+* 5lic:ing on Signu$ button screen@2 should be dis$la*ed"
Screen 2 @

A clic: on Submit button ta:es *ou bac: to the screen@1, !here *ou ma*
login"
Once *ou login, user must be (alidated and a$$ro$riate message dis$la*ed
on a ne! !indo!"
Ques 2, Nou need to create a user interace or dis$la*ing the $erormance
sheet o a customer care eCecuti(e !ith the com$onents organi'ed as sho!n
Qogin
Pass!or
d
Log Sign
Qogin ID
Pass!or
d
5onfrm

Student
create delet
e
hel$ clos
e
Nam
-oll

Ques 3,)rite a $rogram to a$$l* la*out manager to the container"
SESSION 39:
Ques 1,)rite a $rogram to sho! all the e(ents o mouse motion"
Ques 2, )rite a $rogram to sho! all the e(ents o :e*board $ressing"
Ques 3, )rite a $rogram to sho! all the e(ents o !indo! o$eration"
Ques 6, &he a$$let de(elo$ed or acce$ting the dealer details should ha(e a
button to reset the (alues alread* entered" &he a$$let should also contain
the unctionalit* re7uired or retrie(ing data rom the teCt controls and
chec:ing its integrit*" &he ollo!ing chec:s are re7uired on the data
acce$ted:
&he teCt controls should not be let blan:"
&he mobile number entered should be o ten digits
SESSION 3=:
Ques 1,Design the L5atcheKeA Jrame"
Ques2,)rite a $rogram to create a note$ad
Ques 3,5reate a orm ha(ing certain controls,so that !hen *ou $ress a
button all the controls get (alidated"
Ques 6,