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

Java A1

Uploaded by

Rishab Jain
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
0% found this document useful (0 votes)
11 views

Java A1

Uploaded by

Rishab Jain
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
You are on page 1/ 15
QOP Sava Asvawses' af 4] Explain Javea buzzurords ? cae Fave. Rater rany Cloguage "SY Varro nny aa tand and C Many complicated | wacture: poiniers , operator overloatiing , sty “ have beco 1, One of the most usetal features is -the garbage Dy it mokes (eval toca Signs Secures Tava is said-t0 be move secure programming mlers concer doesnot have p " yshieb 1 be embedde ‘applet’ the applet i> j< of computer, urbicl keep: trke vases and Unathorized acce: Portable: Portability is on) atures of j ushich enables the java pro glen. fer example, an applet deve ox operating sy cpus a wide variety of using Java rw and browsers connected to sthe intemet, Rigject Qdented Javea is sald te bea ed progranming tanguage. The primitive implemented as, objects using wrappe’ classes ‘ a t+ allows primitive dala types 4 perforant a code Robust: more Yoloust bec eee > executed ana variety of env Java is me 00g memory management y typed language, it has a strong [ade pent Java anywhere, any Hime jforever't des Jum CJava | Machine) 40 arehivg Povo independent. “The JVM ealed using one operating operating sysier - ithe Tava provi lavebitecture -natwral oF plat lailews the java progyam or on any Sag Can be eveented Multi toreaded © Mulls Oia Java supports mu Lyi threading ulkple operations urbich allows | siroultaneos ly: preqer i is usrile progvams that do Holerpyeled Java enables the creation of Gross platto: nee programs by caropiling into an Intermediate vepve sentation called Tava bylecore. The byte code is interpreted to any Pine on eh batve roc aiaas de so-that Tava provides high performance Dues like Tv, interpretation, machine co High Performance! A Rs CA eg with the help of fe and its steop Weity. Dictyibuled Tava Programming language Supports “Te P/ 1p protocols whieh enables te fava to Support Hthe distibuled enviooment of tHe internet Java alo Suports Romole Method Dnvecatior (Rm), this featu > ected enable: a program 4o invoke Method acrwss a network. Byoamlcr Tava is saidte be dynamic becau Lyte cede moy be dynamically updated on a ties ‘| systemand tt has a dyaamic memory — deatlocatto> (obj ects and garleage collector). Ba i lain briefly about Shing clas ani disa eed io Sting class With evample ? rtorring is a predefined class in java. * Ht can be declared as String mYyshing = "this is onkefssignment” the string class. te “There ave Several predefined methods + boolean equals (string objects) — used to check the eqpality of tuse stings e int length Oo = Returns the length of the shing 2 aha CharAt ( tet index) 2 To know specitié Characters in a Sting Progrars class Shing Ex f public stabe void main (String argst3) f Shing 4itle = “String Example” s Sting lamp= “ cyck"+ System oul printinC” Length of tHe” + titte lengthO): System. oul -printie( “charst index a" 4 HHHe CharAt(3)); if (Lite equals (tam py) System. ou. pinto ("They ave equal’ ele Sistem oul pricy € “They ae nol equal), ’ Y qutpass Length of tHe + 14 Seas index 3s i ia - they ove not 2qual Weare oreronding Jove 7 Define “a tat have same nameand diferea iP num b | Parameters and type of parameters 2 feeling th 2 Same for two ormore meee itis possible § distingutshed by payomerers methods and that co? b¢ pe of parameters. declaration and ty peed Oodaicg f ass is Beeeme thos is said to 62 overt Proce Me sctnnd overioading » is, 0pe of the oe ae of implementing polymorphism. + The veturn type alone is insu RPncre nt tone cites the Same method multiple times. Method 4> Changing the number of parameles. class Addition £ int add Cinta, iot b) Tint sum= ark: yeturn Sum) x jot add Cinta, inthy jot OD 4 PRieesuten = a4 b+ CY veturo sure} Class Graf public State Vord main ( String argsty)t Addthon ob = new Addition), int sums = Ob-addCt,2)! System. out: printto (“sur of the tun integer value! ook ie a PalaCuaye yh pie System. oud - printin( “eum eines integer Tre + su02), q Ef Sur of tum integers value. % Sum of three integers value : 6. Method» Changing Data Types of ea class product ¢ Public tot Proll Cinta, nth, inteds tot prodt -ax bac, Yeturn prod + i Public double Pod (double a, doutle b, double c) E double prod2 -arb*c> veluen prods; ei a elas Gra ft publi static Void main Product obj =netw Producto: int prodt = obj- Prod (1,2, 39; System. out -printin (" Product of the three integers “+P double prodga = obj- Prd Ct-0, 2.013 °%5 System \ aaa bey J \ eye 2 t= 1°” obj-b + = 20 \ \| class Maio f : void main ( String GI args) i pject= new Cali ByRe ference Cto, 20)! ChValue of ar epbject a+ "a b's object iby i objechb)> \ of OF 2om bo. 40 “ Whats is ‘static = Static Koy wor dy-The stake ea eot: Jused for memory manage fe varia Seticd to share the sa elase.the users can ap} and nested ctasses methods ,blacks » belongs to-the class than 0° in: [state keyword is user [that is the same Pe “the static keyword | epplicate fev the following 14. Blocks 2. Variables | I | | {| | | i | || | | \ | | ply stake st | Por a cons Per every insta is a nen-acce nar class Student § Stving name > int yollNo 3 stalic Shing altgName> stabic int counter = 07 public Student( Sting name> Bera eenaine|s, name; this. roliNo = set RotINo ©) % i state int #set RolINoO . counter ++) veturn counters ci Stoic wid setcllg (Sting Void get Stud erttofoO 5 Feo yrr ? Explaie the st 3, Methods the concept ust pad in oe ic mainly ate Koywrord in ee or method of a Blan oor dS with variables > the steke poyurord The a method ble 23 of the class yadable oF ane tant nee of a Class Bier in Tava that is ss modi 4. Clasces. ame) { clignamé = name; } Stern oud: printin C" voilNe #4 this. volINo ‘System. oul. prints CM Clg Names" + elignlameds t + [public class Static Demo f public Static void mae ( Shinglt args) Student -setcllgC" xyz." 9; Student $4 = new Student ("Aico"): Student s2 = new Shident C" Bob"): SA «get Studenttfo 03 $2. get Studenttnto 0; ? Qutub | name: Alice | rote 4 | cllgName: xyz “name » Bob yolINo + 2 cligName: xyz Usit2 WR Explain the process of defining and creating a package with suitable examples ? Package in Tava is a mechanism to encapsulate a group of classes. sub- packages , and interfaces. €Hl Wwe needto do is pat velaled classes into Packages. After that, te can stwply wrife an importelass Prom existing packages. and use it Jreep oP vet | cur program, 4 Package ia container ofa 4 sp oun onok Duron "nef 20}49 shi) euuwrg mau ohw 220002 > wou pron 2421S 2a jag S012 aot yodust ate Bums sw gens odors Age Buss =o you, vpn cqquonen oud P tba eee =P Goa pron 24045 20904 ay 35019 4 A ) eee ino ar SBS pouyaw 9e) tee een 22a Besant > aq wee vadns + SP SHOE wo abeea Jo2sn ap. st 1S roe : sghiet the Us € Baal Keyword io java ured 40 ves a a can Waricitle 2 “ context jerused t.” J pderh ed Becee i rol a jove Ee iFinat car be 4 the Pmal Keywrr Peeeicayiauie that have 9° value pied with the variables a a can bE OP ank final 50 initializot be ib ic called bl Weed final variable. F oe bank final in the static block oy uninifia ye can Vowiatle Hin the constructay onty. “The be inttialtzed vaviak Static also which will | only. tae wat! ave detailed. teaarng of thane. ket | Pinal class stud f | Seb b Clas: books extends stud Void Show) f Ss ‘ y stem. out: printto( "Bovle~ Class methoal")+ % public static otd main (String argstI)s | bovks BA = neo books 0): B1. Shows eryoy Cannot inher art Prom Final stuct clay b Stud § Claw books extend} in the diterent types oP acer aroabos pla ‘herent ty pes of accone specifiers with amples. Aiccess speciPiers are -the koyurmds Uke * public"; TProteclea”, "olefautt" and "privale” uric has its Spectel meaning ts java, it definas the access SSPE BEES rs ctncds and. clases and here the Pcres’ Scape means the area oy space urbere a variable! m& classes oF methods are accessible. >; pablic access speci fiers: +The access scope of the “public” is everyurhere tike im all

You might also like