You are on page 1of 15

Student ID

Experiment#
Date Student Name

Experiment Title: Generics with Interfaces

Aim/Objective: To analyse the implementation of the concept of Generics with Interfaces for the real
time scenario.

Description:

The student will understand the concept of Generics with Interfaces.


Pre-Requisites:

Knowledge:Classes and Objects in JAVA


Tools: Eclipse IDE for Enterprise Java and Web Developers
Pre-Lab:

1. Discuss about the various types of Generics in JAVA.

Theea e two Marn tyPes of 9enesicg fn java


()9enest c olasses
()geneîc mehods.
Genes+c clas seS ase classes that Can bp
used to Stose ol bject oe efexen
ty Pes.
hey dec laxed witha tye faramee
placeholdos Ros He
actual type of object hat wil b
the lass.
Gene me thods
us ed oith
agnents of
Hat
dtee
tye 4Pes.They
flace ho lde Posametes, which c a
he actual type
obiect that
w?t he
the mebhod, assed to
Course Title Advanced Object Oriented Programming ACADEMIC YEAR: 2023-24
Course Code(s) 22CS2103A & 22CS2103P Page 81 of 241
tass genesî Tt
used
class
omeftod. faroe
HoweveT, 241
2023-24
YEAR:
ACADEMIC
moe
be
ame with
of
82
Page
sarcHy tes
Cun to Ces flexible.
în
fett
So of code
tyte ntesfa hat nceSSaay
ey Tn
tosed
S bype
Student
ID Student
Name not the t6
tyecode. the maKe note Programming
aebut Sed and
Generics. esaluStng
the constsan
S, Pas to always Oriented
in
Interfaces heonesiC
oeneiC ecify SPectty hel
o type-
sof
e 22CS2103P
&
22CS2103
AnS
Tn
texfaco be împottant Object
be
Advanced
of
necessity sf Can qen
COLn not
the
Cos To
Discuss
n Code(s)
Course
Experiment# * Title
Course
Date 2
Experiment# Student ID
Date Student Name

In-Lab:

Write a Java Program to identify the Maximum Value and Minimum Value in the arrays of
different datatypes like Integer, String, Character & float by incorporating the concept of
Generics with interfaces.
Procedure/Program:
impos t Java.ut il- AsayS;
intesace TMar MineT>
eind Max(j

class Myclass<T imelements I Max MinY


Psiuate
Public
Myclass T] ossay)
his. asday=asS a

lublic T endMax()
Max axay "I,
eox (T element
:axsay
¡(ele ment Smar)
max elementi

?xe fuxn mery

Course Title Advanced Object Oriented Programming ACADEMICYEAR: 2023-24


22CS2103A & 22CS2103P Page 83 of 241
Course Code(s)
Pos (7 elemant: assayy

min zelement

setusn
J

Rablie cass marn


Rubic staic veíd
marn
Tsrtoges] întay l;34, s,
leot ]
lat
myclass

SoP min
AySiylasew
<Integey Sinteger
welue în
.l,2:2,3CintAay) 3,mycl4 ass<D
s3

îategex sayis: +1ntogex Myclass


Myclass<sts+ng>stang Myclacs ind max()}
obsng 4in(tesstayiermgycAsoa) l
Rind minC )
as
-nginem\aysnc-liansde
May Value:
GoP(in value
+strikgmyc mar c)
Min c)
Date
Course Title
ode(s)Course Experiment#
Maclasspmin wuoass
7 P(
So
SoP( So.P/
S2103A
S2103P &
Advanced eHoat> lchosactes
mayiaue
l
vclue:
max
value.
Object

Oriented
eloatMyclass 4 >
gramming +
4 chcxac ChasaltexMycass Student
Name
chaxactosmyclass.C
elootmyelass Student
loat
fex ID

myclossCnd Myclass
New
ACADEMIC
2023-24
YEAR: (choaatar
ANaayl
t+nd
mycass<>
Page
marl)); (eloat înd f new =
84
of min
241 min ind
C)): Axkag Myclacr
C) mar
achiees
A and can
is:Ie îs: focetuo
methos
oe agene 2023-24
YEAR:
ACADEMIC
241
îs: a
Ctstng
assay
(S: lde of
hasactes
assay
atay înter moxmum it 85
is Page
abtayy marm thot
Rindmin),
Those ho
ade This ce
cfex
an meanS Ploa
intoger chosa 4ule.
stng detines the thecT>
ID Student
Name
Student QloatCloat Tmokn
called
Tmamîn
that erad Programming
which
în in Value
în any
value Tntofalp
in Value
in value in Rsgsam Oriented
Passed
Testvalue
valueyalue nin
vauo
value
max
Rindax()
and
Co,witt 103P
usra 22Cs2
Object
and
Inferences:
Analysis fa &
22CS2103A
Advanced
fntor
d
Data max
Results:
and mar marMin The The
use
by
ase
Course
Code(s)
Experiment# Course
Title
Date
eosily of lased Haut
to otype
methodsfosanete, 241
2023-24
YEAR:
ACADEMIC
whica
tS
eed ects c tte of
86
de ct
C Obje Page
genosi egate obj axe actual
types.
they to
a ea ae
delegatog
enable
he Passed
del
Java. sto ?sactual
Eyee
ee
Resfo
anee. in dItfenent
tyPesthey
shch These
ucp without implementation
fo
the
Student
ID Student
Name code
and
coe classes
The
se lass. witth
se be
mutple Programming
advantages
to to fasametes, will
c *Genesie
methodsi
Generics
&
delog
atos: he hatOriented
callbaCKS be
uged wth
atype
of Placehol
de
11efeent
103P
(In-Lab): seduced. Cseattypes în 22CS2
Object
Generics. biect&
Rettes various theStosed
os
Questions type 22CS2103A
Advanced
Less the
of
benefits and Can Can
about
VIVA-VOCE o o
Course
Code(s)
Experiment# the Discuss
Course
Title
List
Sample
Date 1. 2.
mplanented
oe
ifesent
tgPes
be
can
ces:that
tosfa
ces
în a lasses
Tntes
Geneic
*
common(y
sigle. tup eo
Ghat
Placeholdex 2023-24
YEAR:
ACADEMIC
241
lagg
a
Hhat wítth
of
cale
dBox 87
Page
usually object
C
ass, ctass
BOk
<T
Conventions"
Generics lettS.
The
anost Geclaed
ae a
Name Naming
in
ID Student
Student osametes
s lass
sa is of Programming
twhichHhie
Names ype 9eneC
class
example
Element yes,
They
Qae Oriented
Parameter with
Stoed
actuol
Pasametex, clipub
22CS2103
&
22CS210
tex tyere Object
W-
Key T-TyPe
* Classes
Paaame
cage
we Advanced
"Type Generic used he
about used be
about
Experimentllustrate
# uDe State
Code(s)
Course
Title
Course
Date 3. 4.
set
(T
e)
t t se
trs. tt;u n
Publtc
elace
diceorntholdar Ttesab
le
<t> awd
enterds
be a toxget) ACADEMIC
YEAR:
2023-24
241
of
can with with 88
Page
class
cheT (rra
the
hafof ctaed Test Say)
classos the
actual
yPe.
Seasck t
algorithm. javautil-Aays
seas
Student
ID Name psiate
T
asay;
I
Student
ntesfaCQ
de which
Ts întefaCe strings.
k
search Binaty int
lowro,
and
Ttexatos binary einacy
ay
Seor Programming
example. doubles,
by a
with
implements
integers, class as t Oriented
22Cs2103P
&
22CS2103A
mplemented
t4Peg.
They thisi
Interfaces Pasameter
Public Object
as
thatsuch Pubhc Pubhe
Generic 3 class
types
Publie Advanced
generic
data Procedure/Program:
about
Experiment# a different Course
Code(s)
Create
State Course
Title
Post-Lab:
Date 5. 1.
S
Ctaxget)
thigh)2;
tength; eguals Lmid.
high (atay
(low(asayCmra.
low
Mid
+('
c= etutn
mid
astay.
(Low=
mid 7t
etun
he ?else
Aia while
ie
înt
îndex mplementr
search
aglosilhm
2023-24
YEAR:
ACADEMIC
241
geneic of
at 90
Page
found chSear and
agument
ID
Student
Name
Student eineS
de Binaay
is Programming
6 3
S, 3 Oriented
, element lass binary
calledConstuctes 103P
',,3, do
co 22CS2
Object
and
Inferences:
Analysis 22CS210
&
Advanced
and
Data
Results:
The The he
an
Code(s)
Course
Experiment# Course
Title
Date
Procedure/Program: Post-Lab:
Date
Experiment#
(s) Title
seCourse 2.
Create
the
public method

fox generic a
with
103P
3A &
vanced method
(tGos (it different
‘f(oayri.
Object extends
stoticCT that
types
assoy1S+u
temp tem T sorts
Oriented
î=o:fe of
void obiects an
array

ramming such of Student


Name
obiects Student ID
as
axsbkleSoxt
(TJ bu integers,
co using
ay
doubles, a
length-,
poàe m bubble

ACADEMIC
2023-24
YEAR: omfaxable and sort
(ongth--frtTo strings.
algoritnm.
Page
CoNsay
91 ?tt)
of Test
241 [s+)
urse
Title Evaluator Date
Experiment#

Inferences:
Analysis
and Results:
Data
and

Remark

SostS that he Outut


(if methoanddy
P&
ced Any): asythe of 2
S
detines
Code
bject Copaes
ented that

ming Student
Signature Secured:
Marks
Student ID
then
Name

of
the nteges
axaayof
Evaluator Ps
usng rafnC)
ints method
ADEMIC
2023-24
YEAR: out 50
of

with
Date
bubbkty
the the
Page
92
of content
241

You might also like