0% found this document useful (0 votes)
10 views

Core Java Assignment 2

Uploaded by

Sam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Core Java Assignment 2

Uploaded by

Sam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Page No.

01
Date

Name t Rahul RNishael


Sub CoreJava
class - TYBBA -CA.
Rolno : : 1

Assiqpmeat No o2
Explain tnner class in detatL
)An DNe a olassthat
class is nested
wothinanothen class
2)t all ocos logical qrouping of ela sse that a
ony uSed in one place
of ihenclase in Jeva
Non -Static inner cass, Stotte NetedclasS, Local
Innes class, and Anonu mous lone clace
wInner classes hane access to the Me mbess
CincludBng pavate membersJ of the quter caas
G) nlo Static. nner cla sserxequie Cn ieg tance
oP the outer elast to be instantia ked
6) Static LAeited classes do not quie
instance o the ou ter clals
N Anonyma inner classes ae aeed for Inplementing
interfaces or Rxtending clacSea cwith minimal cadz
A )Annes (lasse ae uded for inplementing
en capsulating and event hunding in TAA
autl'eulaly in G0I applications
priuate,rotechedc
lnner classes Can beprivate
Qackaqe private.
Pags No.] 02
Dats

Whal is collec kion explainollechion rameduok indebeut.


Acollection n Java ls a Frameciosk_fhat provi'dey
Orchiteetune to Stone and monipulateqtcupl of
objecBs.
2) The Collectlon vamé tuork iocludey taten faces.
claeies, cand alqorithms for managing Collection s
2) Conf intenfacesin the Colle ction fra.meca
Arameork
u) List
List,set, Queue, Map
An ordered collection thai Can Contain
duplicate elenent (esg Arrayli'st liakedLigtl
5) SetA Collection that _Caninoi Con tain dupltcate
elements (eq. Han Hag hnet ireeret)
4)QueueiA collection for halding elements pmior to.
prncessina, tupicolly in a fIEO Osder Ceq.Ar
inkedlitPrinlyQueq).
1)Map An obect that maps kes to yalu e4, coith
1
ni duplicake-keqy (eq, Haghmap Treem ap)
) the Aomesaotk incudes algonith mgiee
Seanching Sortiny and shiling thát Can
be applid do collection
q).Che (otection class provided gtatie methods to
manipulale collecti'on
10 Suppoxts qeneAic yPes, enablingq type Sak openationt.
nikied caYchilectwne helps in educing the
development eFFoxt and inpravl the pen formance
o Collection
Date
1.

-Q8 What s the use of.


of Reade
Readen and Writerclass ,

tDRea den and Write classes are_pant of Java's


I/o Cinput /out putJ packageSpecificaly Por
handling chanacken stram
2) The readen class is an abstract class used fo
read chanactet data fromq Son(e
ea fileReader, Buffefed Readeu.
2) The (aiten class is_ an abstract class used to
write chanactex dat a to destination (eqy file orika,
Buffene dWei te)
) These classes hondle tect Filesr cahete encoding
may vog ar bpposed to byk Steeams (ln putShean
Dutputstt an) , ohich handle raw binany data.
s) Readen oeaddata ag. chanahtens and decodes
it usinq the platfor m's default Chanset unless
specifled otheoiseg
6y iten witea Chauachten cdata and en code!
into yfe using the Specifide chanset
a) Theyane idea) for handting ert data dike
eileg con sole, Inputl out pu,
Cornmunication
Both Rea der and witer_ classes Sup por buffeing
fos efftcient Il o opetations
9) he closeC method in both clase4 enturey that
"5eSoucey are Preed ohen the Stream is.
\onger needed
16) Java provid 4 sevenal conCete implernen tatins L
Jike string fe ader,
for dfenent
ChoaJlkvayfea dor, Pointeir, ete
use Coye
Q4: Cyecate a class TeachenCTid., Trare, Oesignation , Salan
Subtect). brite a Jaivc1 proq to acet o' ac heru
and di's play sho tea ch JavaSubfect .Cose
Aray of cb'ect
import(ava:util. Scannen,
cass TeaChen f
int Tid;
String Trotne
Sting Oes iqnation;
double Sahy
Ssring
gublic
Subject i
Teachen Cint tid , trínq tnamey
sting deianation, double Salaiy String Subject) ?
tblg. Tid,= tid,
thie Tnane toname
thts Desigpalion .designation
Ehis. Salany Salang+
this. Sutsjech' = Sabil
publíic yoid, dicplayJ
.(this Subjec: equole Iqnone Case C" Java"))
Systern:Out-println (Tid"1Tid t Nome:" t Tnanet
"0esignation ;" 0esignation
"Salary Salary i", Sutect:'A Subiccd

public class Teacheo Tes+


public Statlc void noin CStringCJ argg) f
Sca bnen Sc neScannen l syeo. in)
System out: print C"Enten uoben od teuthens: "
Teachent] teaches: ne0 Teacheln
for Cint i:0 isn; it1)
Systen. oulp:pointlo (" Cntes details fo teache'
+ i+ 1));
Sysherm ou4 peint C"1d:")
(nt tid : ScnextIntLJ:
Se-rertLineC
Sustem. Out-print("Nane
String name Sc.. nertline Li
System out print (" Dsiqpai on:");
String desiq nat ion Sconertlint li;
Sys fero 'oul print (aalar);
double sal ary Sc.next Doubl e0;
Sc.nertline ();
SygHm. bul.peint (subect ");
sting Subj eck =Sc. rextlingt),
teacheili :neos Teachex (ti£, namt, designa tín
Salaty, Subje ct);
S4skm.out-println,("Teach ens oho teach Java:):
for CTeachen feachen ttachensJ
Pago No.
Data

95. bikJava. prog fo


to num
of
-and.Chanfroma ile,
Coun
diqits,.Spaces,
imp ontava.io.,
public class fi le Chapa cer Coun
-public shaHe vod _main Csting] arg ?
int diqiks: o, Spaces o, chnactens 0,
tryCBu ffen.ed Reader bre necos Beffestd
Burfened Reader Cnecu Fle Reader (" inpultrE "))
int -ch
while Cch br tead cJ)-1
Digi! Cch))
- else
echanactexthhites pa ce CchJ)
Spases tt
chanachtenstt
catch (IOEx cephin e) 1
eprint ShackTrace ()
Sys tem:out println (" Digíts:"t diqitsJ:
Suysterm ub println (MSpaces:" Space
Systenout pintn("Changctas:"t chanacten J;
Pege No
Date

Q6 ie a Java proq: to accept n' in eg es fiom the usen bk


Store them in an Anaylist Collechion Disp lay elementr
in teven se Orden

impat java. util: Arraylist ,


impot java.util . Collec tions;
Importjava. util. Scann en;
public class Revense Araylist
public Statie void mgin (Stringll args)
Scanner SeSe snew Scannen aystemio.J
ArrayListK Inkqen IOumbens =
Eneay Arayl-isisl,
ArrayLisi<zL)
Syskem .b prini ( Enten num d inteqen si"
Ini n Sc. nertbntl
Sus tem. out paintlo (" En ten the inkegens"J;
fox Cin ti=0 isn itt)
Dumbe Oddlsc. nex tIntCJ]

Collection s eVeT Se Chumnbers


System QutputÍintla (Melements neRrte
OTder:")
Por Cint number numbers)
num
Sys km. but:printn Cnum be r)j

You might also like