[PDF] Part I. Multiple Choice Questions (3 points each):





Previous PDF Next PDF



Part I. Multiple Choice Questions (3 points each):

Generics and parameterized types eliminate the need for downcasts when using Java Collections. III. When designing your own collections class (say a linked 



Operating System Multiple Choice Questions ? - m.central.edu

answers chapter 2 to practice test questions: Standard C library functions



Part I. Multiple Choice Questions (3 points each):

(a) If a parameterized type is not specified the code will not compile. (b) No parameterized type is needed because Java will use the Object class as a 



Java Mock Test - TutorialsPoint

C - An immutable object is an instance of an abstract class. Page 5. D - None of the above. Q 21 - What is local variable?



AP Computer Science A 7th Edition

Multiple-Choice Questions on Inheritance and Polymorphism . in this review book is part of the AP Java subset unless explicitly stated otherwise.



AP Computer Science Principles Course and Exam Description

multiple-choice questions and this raw score is Programmers integrate algorithms and abstraction to create programs ... write programs in Java.



Enterprise Java - TYBSCIT Regular - 5 SAMPLE MCQ Questions

the network within a Java application is known as ______ d. leaky abstractions ... TYIT Semester V - AWP Sample Multiple Choice Questions.



Object oriented programming in java mcq with answers pdf

Object oriented programming in java mcq with answers pdf The Java language provides an effective level of abstraction to non-Java pointers developers.



AP Computer Science Principles Course and Exam Description

multiple-choice questions and this raw score is Programmers integrate algorithms and abstraction to create programs ... write programs in Java.



Java-Interview-Questions.pdf

Java Interview Questions. 2 / 30. 1.4 Abstraction. Abstraction is the process of separating ideas from specific instances and thus develop classes in terms 

(a)DynamicBinding (b)Polymorphism (c)Inheritance (d)Encapsulation (newString("nophobia")).substring(3); (a)"arachobia" (b)"arnophobia" (c)"arhobia" (d)"rachobia"

3.Whenwouldyouuseaprivateconstructor?

(a)Whenyougetboredwithpublic (d)Never,it'snotallowed (a)char (b)boolean (c)byte (d)int 1 publicclassSwitch{ publicstaticvoidmain(String[]args){ inti=1; switch(i){ case0: intj=0;

System.out.print(j);

case1: intj=1;

System.out.print(j);

case2: intj=2;

System.out.print(j);

default: intj=-1;

System.out.print(j);

(a)12-1 (b)1 (c)12 (d)Thecodedoesnotcompile

Integer[]someInts=newInteger[100];

intsum=0; for(Integeri:someInts) sum+=i;

System.out.println(sum/someInts.length);

(a)0 (b)thesumof100integers (c)NullPointerException (d)thecodewillnotcompile 2 charx='A'; while(x!='D'){ switch(x){ case'A':

System.out.println(x);

x='D'; case'B':

System.out.println(x);

x='C'; break; case'C':

System.out.println(x);

x='D'; default: continue; (a)A D C (b)A D C D (c)A D (d)A (a)aclassobjectandaclasstype (b)anyprimitivetype (c)booleantypeonly (d)classtypesonly (a)voidhandle(ActionEvente) (b)voidactionPerformed(ActionEvente) (c)voideventDispatched(AWTEvente) (d)StringgetActionCommand(ActionEvente) 3 publicclassAextendsException{...} publicclassBextendsA{...} publicclassCextendsB{...} publicvoiddoStuff()throwsA,B,C

Thefollowingcodedoesnotcompile.Why?

try{ doStuff(); }catch(Aa){ a.printStackTrace(); }catch(Bb){ b.printStackTrace(); }catch(Cc){ c.printStackTrace(); }finally{

System.out.println("Iloveexceptions!");

becaught.

12.Whatistheoutputofthefollowingprogram?

publicclassA{ publicstaticintdoStuff(doublex,doubley){ return(int)(x/y); publicstaticvoidmain(){ floatx=6.0; inty=11; x=A.doStuff(y,x);

System.out.print("x="+x+",y="+y);

(a)x=1,y=11 (b)thisprogramdoesnotcompile (c)x=6.0,y=11 (d)x=1.0,y=11 4 privateDatetoday; +today.toString()+"is"+favColor); //...SomewheresomeMethodiscalled...

Stringname="Topato";

StringfavColor="Green";

someMethod(favColor,name); (a)thiscodewillnotcompile (d)NullPointerException intx,y,z; y=1; z=5; x=0-(++y)+z++; (a)x=4,y=2,z=6 (b)x=4,y=1,z=5 (c)x=3,y=2,z=6 (d)x=-7,y=1,z=5

15.Anarrayobject,ArrayOne,iscreatedas:

float[][]ArrayOne;

ArrayOne=newfloat[20][10];

themethod? (a)float[][]someArray (b)floatsomeArray[] (c)float[]someArray[20] (d)floatsomeArray[20][10] 5 classReindeerthrowsHoHoHoException{...} Why?

FileoutFile=newFile("Santa.txt");

Reindeerr;

for(inti=0;i<9;i++){ r=newReindeer("Reindeer"+(i+1)); outObjectStream.writeObject(r); (b)Only8Reindeerobjectsarewritten tothefile?

II.Whenthedatabufferisfull

III.Whentheclosefunctioniscalled

(a)Ionly (b)IIIonly (c)IIandIII (d)IIonly

18.Whywouldaclassbedeclaredasabstract?

(b)Sothatitcanbeusedasaninterface (c)Sothatitcannotbeinheritedfrom (d)Becauseithasnoabstractmethods (b)Noneoftheseistrue (c)ItalwaysforcesCtobecomeabstract 6 publicclassB{...} (a)ClassTextendsB. A. (d)ClassBextendsA.

Giventhefollowingvariabledeclaration:

Personp=newPerson();

Students=newStudent();

Undergraduateug=newUndergraduate();

Whichofthefollowingassignmentsarelegal?

I.p=ug;

II.p=newUndergraduate();

III.ug=newStudent();

IV.ug=p;

V.s=newPerson();

(a)IIIandIV (b)IandIV (c)IandII (d)II,IIIandV pile? abstractclassBirdimplementsLivestock{} classChickenextendsBird{} (a)Birdbird=newChicken(); (b)Livestocklivestock=newChicken(); (c)Birdbird=newBird(); (d)Noneofthesewillcompile 7 responsibilitiestothecompiler. whenusingJavaCollections. classes. (a)IandII (b)IIandIII (c)I,II,andIII (d)IandIII classA privatevoidsomeMeth()

System.out.println("fromclassA");

classBextendsA publicvoidsomeMeth(Stringx)

System.out.println("fromclassB:"+x);

(a)methodoverriding (b)methodoverloading 8 classBox{} classSuperBoxextendsBox{}

I.Boxb=newBox();

II.Boxb=newSuperBox();

IIIBoxb=newSuperBox(); (a)I,II,III (b)IIonly (c)IandIIIonly (d)Ionly privateintf(intx,inty){ if(x==0){ returny; }else{ returnf(x-1,y+1); (a)0 (b)17 (c)Thisrecursionisincorrectinsomeway. (d)72 privateintg(intnum){ if(num<=1){ return1; }else{ return3*g(num-1)+g(num-2); (a)Thisrecursionisincorrectinsomeway. (b)43 (c)4 (d)13 9 intf(intnum){ if(num<=2) returnnum; else returnnum*g(num-1); intg(intnum){ if(num<=2) returnnum; else return(num-1)*f(num+1); (a)1,2,6,24,... (b)Thisrecursionisincorrectinsomeway. (c)1,2,3,6,... (d)1,2,6,16,... 15 23
21
19 publicstaticvoidprintNums() intn;

Stringline;

line=inFile.readLine(); if(line!=null){//IfnotEOF.. n=Integer.valueOf(line).intValue(); outFile.print(n+""); printNums(); outFile.print(n+""); (a)1523211919212315 (b)1921231519212315 (c)15232119 (d)19212315 10 (A)inthefrontoftheclassroom.Thankyou. 11

Thispageisleftblankintentionally.

12 example,iftheinputis... 38
86
92
55
83
42
90
-1 thentheoutputshouldbe:

Totalnumberofgrades=7

NumberofA=2

NumberofB=2

NumberofC=0

NumberofD=0

NumberofF=3

TheAgradesare:92,90

13

Solutionforprogrammingquestion1:

14 histoybag.

GenderFirstNameLastNameStatus

MJackFrostBad

FCindyLouWhoGood

MRudolphRednose-ReindeerGood

Frost,JackCoal

Who,CindyLouPony

Rednose-Reindeer,RudolphBicycle

LumpsofCoal:1

Bicycles:1

Ponies:1

thatmightbethrown. 15

Solutionforprogrammingquestion2:

16

Animalshouldnotbeabletobeinstantiated.

classes. 17

Solutionforprogrammingquestion3:

18 19

Solutionforprogrammingquestion4part1:

publicclassNode{ //addyourclassvariableshere //addyourconstructorsandmethodshere 20

ANodeobjectwhichpointstothetopofthestack

object) thestack. object. empty,returnanullobject. 21

Solutionforprogrammingquestion4part2:

22

NoSirpreferprison

Racecar

StrawWarts

neveroddoreven

Oozyratinasanitaryzoo

isasampleoutput.

Thestring:'Trythis'isNOTapalindrome

23

Solutionforprogrammingquestion5:

24
quotesdbs_dbs17.pdfusesText_23