Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
79 views
Oracle
oracle
Uploaded by
yande wade
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save oracle For Later
Download
Save
Save oracle For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
79 views
Oracle
oracle
Uploaded by
yande wade
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save oracle For Later
Carousel Previous
Carousel Next
Save
Save oracle For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 159
Search
Fullscreen
section 1-5 oracle java programming MONDAY, OCTOBER 18,2018 karre jawa oracle java programming midterm and section 1 -§ Java programming Section 1 (Answer all questions inthis section) 410. The function of Garbage Collection in Java is: Mark for Review (1 Points “The JVM uses GC to clea the program output. Memory occupied by objects with no reference is automatically reclaimed for reuse. (*) ‘As Java programmer, we have to call he GC function specifically inorder to manage te Java Memary. 41, Which ofthe following statoments is NOT tue ofthe Java programming language? Mark for Review (1 Points ‘Al source code is writin in plain text es with the extension java Java source code fles are compiled into cass fles by the javac command. “The javac.command can be used to run a Java application. (*) [A cass file contain platform independent bytecode, Correct Correct 2. Which of the following statements deserbe the Java programming language? Mark for Review (1 Points Java is a high-evel programming language, ‘The Java programming language includes a garbage collection feature. Java isan object orented programming language. All ofthe above (*) ABOUT ME saree £29) iow my complete profte BLOG ARCHIVE ¥ 20181) ¥ october (1) kare jowa orci java programming rater ane 800Correct Comtect 3. Given the java snippot below public class Foot public void testFoot int y=t00; , ) Which of th folowing statomants is TRUE? Mark for Reviow (1 Points Compile error, a the variable x snot intaize, Variable x resides in the stack area, an variable y resides in the heap ofthe JVM, ‘Variable x resides inthe heap area, and variable y resides inthe stack of the JVM (*) ‘Variable x stays inthe heap area, and variable y resides in the method area ofthe JVM. Correct Correct 4, Which of the following converts a human-readable fe ino aplatform-ndependent code file in Java?’ Mark for Reviow (1 Points JRE. wok Javac command (*) java command Incorrect Incorract. Refer to Section 1 Lesson 1 5. Java allows the same Java program to be executed on matiple operating systems. Mark for Review (1 Points Tae (1) False Correct Comtct 6. Which ofthe folowing statements describe Java technology? Mark for Review (1 Points[tis a programming language Itis a development environment. Iisa deployment environment. Al ofthe above (7) Incorrect Incorrect. Rel 7. During runtime, the Java platform loads classes dynamically as required. Mark for Review (1) Poinss Tae (1) False Correct Correct 8. One ofthe primary goals ofthe Java platform sto provide an interpreted, justin-ime run time envionment. Mark for Review (1 Points Tne (+) False Incorrect Incorrect Rel 8. Given the folowing output from the Minor 6c: [GC [DetNow: 4082K->64K(4052K:), 0.0429742 secs) 9950K->7748K(22704K),0.0431096 eocs] \Whicn ofthe folowing statoments is TRUE? Mark for Reviow (1 Points Entire heap is 9360%. Young Generation usage decreased by 3968. *) “The pause time spent in Young Generation is 0,0431096 “The size of Eden space is 032k Incorrect Incorrect. Refer to Section 1 Lesson 2. 10. Given the folowing code srippet String str = new Stng( "Hello; The "Hello" Sting literal wil e located in which memory area inthe JVAE during runtime? Markfor Roviow (1) Points In the Heap area ofthe runt data area inthe JVM, In the Method area of the un-sime data area inthe JVM, In the Stack area of the runtime data area in the JVM In the constant pool area ofthe runtime data area in the JVM. (*) Incorrect Incorrect. Refer to Section 1 Lesson 2. 11. Given the fallowing code srippet ‘String str = naw Sting( Hello” ‘The str variable wil be located in whicn memory Review (1 Points aa in the JVM during runtime? Mark for strwil stay inthe heap area of the run-sime data area inthe JVM. stew tay inthe method area ofthe run-time data area inthe JVM stew layin the stack area ofthe runtime data aea inthe JVM. (*) stew tay inthe heap area ofthe constant pool run-time data area in the JVM. Incorrect Incorrect. Refer to Section 1 Lesson 2 12, in whicn a (1 Points cof heap memory ae newly created objects stored? Mark for Review Survivor Space 0 ‘Survivor Spaco 1 Eden *) Tenured Incorrect Incorrect. Refer to Section 1 Lesson 2. 13. Which ofthe fotowing allows the programmer to destroy an objec referenced by x? Mark for Review (1) Points xromovel)xfnalie() xeelete0) Only the garbage collection system can destroy an abject. (*) Correct Correct 14, Which of folowing statements describes Parallel and Serial Garbage collection? Mark for Review (1 Points [A Serial garbage collactor uses multiple threads to manage heap space, ‘APacallel garbage collector uses muliple treads to manage heap space. (*) ‘APacallel garbage collector uses multiple reads to manage stack space. [A Serial garbage collector uses multiple threads to manage stack space. Incorrect Incorrect. Refer to Section 1 Lesson 2 415, Which ofthe folowing statements is NOT TRUE for the JVM heap? Mark for Reviow (1 Points Java Developer can explicitly allocate and deallocate the Heap Memory. () ‘The Heap can be managed by the Garbage Collector. “The Heap can be shared among ll Java tveads. Class instance ane arays are allocated inthe Heap Memory. Correct Correct 1. Given the java snippet below: public class Foot public void testFoot) int y=t00; ? ) Which ofthe following statements is TRUE? Mark for Reviow (1) Points Compile error, as the variable x's notintaized, ‘Variable x resides inthe stack aren, and variable y resides inthe heap of the JVM.Variable x resides in the heap area, and variable y resides inthe stack ofthe JVM () Variable x stays inthe heap area, and variable y resides inthe method area of the JVM. Correct Comet 2, Which ofthe following statements describe the Java programming language? Mark for Review (1 Pines Java is ahigh-evel programming language. “The Java programming language includes a garbage collaction feature. Java isan objet orented programming language. All ofthe above () Correct Correct 3. During runtime, the Java platform loads classes dynamically as required. Mark for Review (1 Points Tae (+) False Correct Corect 4. Which of the folowing statements is NOT TRUE about the JVM? Mark for Review (1) Points ‘The JVM isa vival Machine that acts as an intermediary layer between the Java Applicaton ‘and the Native Operating System. The JVM reads byte code from tie class file, and generates machine code, “The JVM does not understand the Java language specification “The JVM reads Java source code, and 7 translates it into byte code.) Incorrect Incorrect. Refer to Section 1 Lesson 1 5. Where does an object ofa class get stored? Mark for Review (1 Points Slack areaMethod area Inthe fle Inthe database Heap area (1) 6. Java allows the same Java program to be executed on multiple operating systoms. Mark for Review (1 Points Tw (1) False Correct Corrct 7. Which ofthe folowing converts @ humar-seadable fle into a patform-ndependent cod fle In Java? Mark for Review (1) Points JRE. sok javac command (*) Java command Correct Contoct 8. One ofthe primary goals ofthe Java platform sto provide an interpreted, just in-ime run lime envionment. Mark for Review (1) Points Tue (1) False Correct Correct 9, Which of folowing statements dascrites Parallel and Serial Garbage collection? Mark for Review (1 Points [A Serial garbage collector uses multiple threads to manage heap space.‘APaxallol garbage collector uses multiple treads to manage heap space. (*) ‘APacallel garbage collector uses multiple treads to manage stack space [A Serial garbage collactor uses multiple threads to manage stack space. Correct Correct 10. Givon the folowing output rom the Minor Gc: [GC [DetNow:4082K.>64K(4032K), 0.0428742 secs) 9950K->7748K(22704K),0.0421096 secs] \Whicn ofthe following statements is TRUE? Mark for Review (1 Points Entire heap is 9350. Young Generation usage decraased by 3968. (*) “The pause time spent in Young Generation is 0.0431088 “The size of Eden space is 032K Correct Comet 11, Which ofthe folowing stalomonts is NOT TRUE for the JVM hoap? Mark for Reviow (1) Points ava Developer can explicitly allocate and deallocate the Heap Memory. () ‘The Heap can be managed by the Garbage Collector. “The Heap can be shared among ll Java tveads. Class instance ane arays are allocated inthe Heap Memory. Correct Correct 12, Given the folowing code snippet: String str = new String( "Hallo"; felo* Sting literal willbe located in which memory area in the JVM during runtime? Mark for Review (1) Points In the Heap area ofthe run-time data area inthe JVM, In the Method area of the un-ime data area inthe JVM, In the Stack area of the runtime data area in the JVM.Inthe constant pool area ofthe run-time data arva in the JVM. (*) Incorrect Incorect. Refer to Section 1 Lesson 2 413, Given the following output fom the Minor GC: [GC [DetNew: 4082K.>64K( 4052), 0.0428742 secs) 9850K->7748K(32704K),0.0431096 eecs] \What estimated percentage ofthe Java objects wl b promoted from Young space to Tenured space? Mark for Review (1 Points 02 oa 060 os 09 Incorrat Incorract. Refer to Section 1 Lesson 2. 14, Which ofthe folowing aliows the programmer to destroy an object referenced by x? Mark for Review (1 Points xr0movel) nae) xelete) ony garbage calection system can destroy an object. (*) Correct Correct 15, Given the following code snippet: String str = new String( "Hallo"; ‘The str variable wl be locate in whicn memory area inthe JVM during runtime? Mark for Review (1 Points sr wil tay inthe heap area of tho run-sime dala area in tho JVM, stew stay inthe method area ofthe run-time data area inthe JVM strwil stay inthe stack area ofthe runtime data area inthe JVM. (*)si wil tay inthe heap area ofthe constant pool run-time data area inthe JVM. Correct Corect questions inthis secton) 1. Which ofthe following commands allows a developer to see te elects ofa running java application on memory and CPU? Mak for Review (1) Points javac visual () javap Correet Contec 2, HotSpot has an HSDIS plugin to allow dsassembly of code, Mark for Review (1 Pins Tae (+) False Comect Correct 3, Which ofthe following commands is used to launch ajava program? Mark for Review (1 Points Java visual java) javop Incorrect Incorrct. Refer to Section 2 Lesson 1 44, Before we can use the jal lool we frst have to use the jes tool o aban JVM process id numbers. Mark for Review (1 Points Tne ()Correct Correct 5. Givan the folowing information int too, db paused at line 9. public static void method i 10 x=100, my public slate void method) Cade: ©: bipush 100 2:pulsialc #7 Field x S:retun Whicn statement is rue? Step completed: “thead-main’, Example.method! (in Mark or Review (1) Points 1 bce “The line=11 means the jb executed line 11 bytecode in the methost method. ‘means the db executed the last bytecode instruction in the method! method. (*) means the jb execited 5 lines ofthe source code From the bytecode, we can assume the Variable x isan instance variable, Correct Comoct 6. The javac command can be used to display natve code in Java Mark for Review (1 Points Tw False () Incorrect Incorrect. Rel 7. The jst tool can be used to monitor garbage collection information. Mak for Reviow (1) Poinis Tne) False 3, Which ofthe flowing structures are contained ina Java class fle? Mark for Review (1 Points major_version|Al ofthe above (7) ‘The bytecode fora Java method is located in which stuctue in the Java clas fle?” Mark for Review (1 Points magic accass_fags| method_Info(*) ajor_version| Which structure inthe Java clas file contains the ne number information forte orginal source fle? Mark for Review (1 Points method Info) this_ class fled_nfo cp_info \Whin ofthe following commands can be used to transate Java source code into bytecode? Mark fr Review (1 Points java Javac ¢) jt jstat Correct Cottct 8. Which ofthe following commands can be used to monitor the Java Viual Machine statistics? Mark for Review (1 Points jstat) javop javac imapIncorrect Incorrect. Refer to Section 2 Lesson 1 9, Which ofthe following statements is NOT TRUE forthe eb command? Maré for Review (1 Points jb can display tho source code. {db can set ho break pont fr the program. {sb can dump the stack ofthe current thread. jb can track the GC activity of tre rogram. (*) Incorrect Incorrect. Refer to Section 2 Lesson 1 10, The class file contains the definition it inher from the superclass, Mark for Review (1 Points Te False () Incorrect Incorrect. Refer to Section 2 Lesson 2 11. Given the fllowing instance variable ube vos foo( Int esses; ) Whi ofthe following statements is NOT TRUE? Mark for Review (1 Pins “The variable jis a local varable “The a86888 isan ints Hera, ter come, the number wil stay in he constant pao “The variable ‘and the eral 88808 are stored inthe method_info.(*) “The field descriptor forthe variable lis | Correct Cortct 12. The atrbutes_count item indicates how many stibutes are contained within 8 methos. Mark for Review (1 Points Tae)False 10. Like in the Java source code fle, one Java class fle can contain multple class deftons. Mark for Review (1 Points Twe False (*) Correct Correct 13, Given the following declaration ofthe method tot: publi static void test(String s, int \Whicn ofthe following is the desexptor ofthe test method in the class fle? Mark for Review (1) Points (GavatangiStingintyy (Gavattang’stingV ¢) ‘ViUiavallang/Steng:) (Gavattang'Stingjava lang integer) Incorrect Incorrect. Refer to Section 2 Lesson 2 14, Given the folowing class structure: public class Shape ‘eid foo) ) public class Clee extends Shapet void craw > Which ofthe folowing statomonts is TRUE? Mark for Reviow (1 Points “The foo method definition appears in the Circe class. “The Cirle class contains both the foo and draw method definitions “The foo method defnton s only contained in the Shape class. *) Ifa Circe objects instantiate, the constructor of Circle wil call the constructor of Shape, Incorrect Incorrect. Refer to Section 2 Lesson 2. 15. na valid Java clas file, the magic numbers always: Mark for Review (1 Points2 CAFEBABE (*) 1618 BABECAFE Incorrect Incorrect. Refer to Section 2 Lesson 2. Section 3 (Answer all questions in this section) 1. opcode invokespecial i used to invoko an instance Iiaizaton methed. Mark for Reviow (1 Points Tw (1) False Correct Correct 2. Bytecode is an intermediate representation ofa program, somewhere between source code ‘and machine code. Mark for Review (1 Points Tne) False Correct Correct 4, To inspect bytecode, which option is Used with the javap command to disassemble the class file? Mare for Review (1 Points 0) Incorrect Incorrect. Refer to Section 3 Lesson 1 4. Choose which opcode is used to load an in from the local variable tothe operand stack, Mark for Review (1 Pointsload toad () Incorrect Incorrect. Refer ta Section 2 Lesson 1 5, Java bytecode ie generated by the javac command, Mark for Review (1 Points ‘Tw (1) False Correct Correct 6. Choose which opcode is used to push an int constant Sento the operand stack. Mark for Review (1 Points feonst $C) lees load s laloae_s ines Incorrct Incorract. Refer to Section 2 Lasson 1 7. clas fs are loaded inlo memory all at ence, when a Java application is launched. Mark for Review (1 Points Ts False () Incorrect Incorrect. Refer to Section 3 Lesson 2 8. The Java developer can define a numberof additonal or custom dlassloaders. Mark or Review(1 Points Tne (+) False Correct Correct 98, Which ofthe following statements fs NOT TRUE for the Class. orName(‘HelloCiass") ‘mathad? (Choose tree) public class Foot public void test (Class forName("HelloClass) , ) Mark for Review (1 Points (Choose al correct answers) ‘The forName() method does not intaizs the HelloClss.(*) “The forName() method returns the Class abject associated with the HelloClass. The forName() metod does not oad the HelloCas cass into the Java Runtine, () In ths example, the Class forName("HelloClass") will use the ClassLoader which loads the Foo class, ‘The forName method wil instantiate @ HoloClass object. (*) Incorrect Incorrect. Refer to Section 3 Lesson 2 410, The process of inking involves which ofthe following processes?” Mark for Review (1 Points verification preparation All of the above (1) Incorrect Incorrect. Refer to Section 3 Lesson 2. 11. In the ClassLoader hierarchy, which of te following isthe ony lass loader that does NO have a parent? Mark for Review (1 Pointscustom class loader application class loader bootstrap class loader (*) extension class loader Incorrect Incorrect. Rel 12. Which ofthe folowing exceptions is thrown by the loadClass() method of ClassLoader class? Mark for Review (1 Points 1OBxception SystemException ClassFormatérror CassNotFoundxception (*) Incorrect Incorrect. Refer to Section 3 Lesson 2. 413, The same class cannot be loaded by the JVM more than one time. Mark for Review (1) Points Twe False Correct Correct 14, Which ofthe folowing from ClassLoader wil load the rar, the Java core clsses which are present inthe java. package? Mark for Review (1) Poinss Extension Class Loader Custom Class Loader Bootstrap Class Loader (*) ‘Application Class Loader Incorrect Incorrect. Refer to Section 3 Lesson 2.415, The System or Application ClassLoader loads Java classes fom the System Classpath ‘This classpath is sel by the CLASSPATH environment variable. Mark for Review (1 Points False () Section 4 (Answer all questions in this section) 1. Whats the output rom the folowing code? String 8= "9." ‘Scanner se = new Scanner while (schasNext()) System out-pint(sc.nex() +"); Mark for Review (1 Points ap abet) abe Correct Cortct 2, You declare a method publi voi acti Student s}) Which of following arguments can be passed into the method? (Choose Two) Mark for Review (1 Points (Choose all correct answers) “Type of Object lass Interface “Type of Student class (*) “Type of he subclass of Student (*) Incorrect Incorrect. Refer to Section 4 Lesson 1 3, Which thee are vai declarations fora float value? (Choose Three) Mark fr Review (1 Points (Choose all correct answors)float = 2.0% (+) float = 3.01; float f= 0x345; *) float = 1.0; Incorract Incorrct. Refer to Section 4 Lesson 1 4, Which wo slatements prevent a mathod from being averrden? (Choose Two) Mark for Review (1 Points (Choose all comect answers) Void final act) Final abstract void act) Slate inal void act) () Final vole act) 0), State void at) 6. Which ofthe folowing operators are relational operators?(Choose Two) Mark fr Review (1 Points (Choose al correct answers) Incorrect Incorrect. Refer to Section 4 Lesson 1 7. Which ofthe following operators are logic operators ?(Choose Two) Mark for Review (1) Poinss (Choose al correct answers)480) irs) 9. Whats the output fom the flowing code snippet? intieo, System.outprintnci=" +1" 5) (1 Points Dy; Mark for Review “The code will compile and print" “The code will compile and print “The code will not compile Te code will comple and print it jt “The code will compile and print 2, Which stalomentis a syntactcaly corect way to declare an Array? Mark for Review (1) Points inti int 234.81; inti) Inti: ¢) Incorrect Incorrect, Refer to Section 4 Lesson 1 2. Using the code below, what willbe the output fa Student objec is instantiated? public class Student { public Student) System out print"), supe) ‘System out print(2") ) Mark for Review(1 Points “The code will not compile. () Correct Cortect 4, What is the final value of result from the follwing code snippet? inti= ints int result = result= result +; Mark for Review (1 Points ew int 3 “The code will compils, result has the value of 0 “The code will compile, result has the value of 2 The code will not compile, resullhas the vale of 2 “The code will compile, result has the value of 1°) [An exception i thrown. Correct Correct 5. Whats the output rom the flowing code? System out pit('="} forint =O; < 10+ break system out. print ). Mark for Review (1) Poinss 23 otaese769 Incorrect Incorrect. Refer to Section 4 Lesson 16, Examine the fllawing Classas: Student and TestStudent \Whatis the output rom the prints stalament in TestStudent? publ class Student { rival int studentlé publi Student student public static int got Student return student ) public class TestStudent { Public static void main(String args) { Sludent 1 = new Student Student 2 = new Student Student 33 = new Student(: ‘System our.prinin(Student.getStudentle)); ) Mark for Reviow (1) Points “TestStudent wil throw an exception No output. Compilation of TestStudent falls (*) Incorrect Incorrect. Refer to Section 4 Lesson 1 7. Which of following (1) Points tionships doos not use inheritance? Mark for Review Car and Te () Pople and Student Bank card and Credit Card ‘Animal and Cat Correct Correct 8. Which statomonts are rus?(Choose Thres) Matk for Review (1) Points (Choose al correct answers) Since a constructor can not retum any vale, it should be declared as void‘You can use accoss modifirs to control which other classes can cllthe constructor. (7) You can declare more than one constructor ina class declaration") constructor can nol be overloaded, Ina constuctor, you can call a superclass constuctr.(*) 9. Whats the output rom the folowing code snippet? intieo,0; Frist ‘System out pith (1 Points FETE RUD: Mark for Review “The code will compile and print "1 “The code wil compile and print "2 j=2" “The code does not compile “The code will compile and print" Te code will compile and print Incorrect Incorrect. Refer to Secon 4 Lesson 4 410. Which two statements best descrive data encapsulation? (Choose Two) Mark for Review (1 Points (Choose al comect answers) “The access modifier to member data i private. () Member data can be modified direct. Methods provide for access and moalfcation of data. (*) “The access modifier fr methods is protected Incorrect Incorrect. Refer to Section 4 Lesson 1 11, Whats the output rom the folowing code? intxzo,)hilopee3) ‘System out printing + (1) Poinis + yh; Mark for Review 22 320) 23 a3 Incorract Incorract. Refer to Section 4 Lasson 1 12, The folowing code can be compiled, TeuelFalse? byte b= 1 b=b+ 1; Mark for Review (1 Points Ts False (*) Incorrect Incorrect. Refer to Section 4 Lesson 1 13, What isthe output from the following code srippot? ine ryaray=(1.2.34, int sums0; for (nt x: myzeray) ‘System.cutprinth(’sum="+ sum); Mark for Review (1 Points “The code will not compile 20 150) Incorrect Incorrect. Refer to Section 4 Lesson 1 14, Which offoouing staments ae tru when you create a object from class Object at runtime as seen below: (Choose Three) javalang.Object obj = now java lang. Object, Mark for Review (1) Points (Choose al correct answers)Memory is allocated fora new objec, if available.) Reference obj canbe reassigned to any other type of object. (*) “Ths Object instance will not be ereated because you never defined class Object. ‘Anew instance of class Objects created. *) Incorrect Incorrect. Refer ta Section 4 Lesson 1 15, What isthe output from the following code snippet? public class Tas ( UbIE static void main(String args) { System out.prinin(t * 2 +"ava" * 3), ) Mari for Reviow (1) Points “The code does nat compile, The code will comple and print "12javas™ “The code wil compile and print "java" “The code will compile and print "java" The code will compile and print java" Incorrect Incorrect. Refer to Section 4 Lesson 1 1. Which of otowing elaionshis does not use Inhertance? Mark for Review (1) Points People and Student ‘Animal and Cat Bank card and Cracit Care Car and Tre () Correct Corect 2, Whats the output rom the folowing code? invxeo: Int y=5: of yn Diee<3) ‘System.out print *"* + y); Mark for Review (1 Points320) 33 23 22 Incorrect Incorrect. Refer to Section 4 Lesson 1 93, Which stalomentis incorrect regarding @ constructor? Mark for Review (1 Points When no constructors defined inthe clas, the compiler wil create default constructor “The default constructor italizes the instance variables. ‘Aconstructor can not retum value, must be declared a8 voi. (*) “The default constructor is the no-parameter constructor Correct Corect 4. What Is the output from te following code snippet? for (int i= 0;1< 105444) in==3) break: , ‘System.out prin; Matk for Reviow (1 Points “The code will compile and print "123" “The code does nat compile “The code will compile and print "0123" “The code will compile and print "012" (*) Incorrt Incorract. Refer to Section 4 Lesson 1 5. Aclass can be extended by more than one class. Tus or False? Mark for Reviow (1) Points Te?) FalseCorrect Comect 6. Whats the output from the folowing code snippet? String str = "java charl] e= {3,8 W.'a System out pith(strt.equalse) ‘System.outpith(t ==); Mark for Review (1) Points Te code will comple and print "rue tue" “The code will compile and print "als, trust “The code doas not compile. (*) “The code will compile and print "als false" “The code will compile and print "rue false" Incorrect Incorrect. Refer to Section 4 Lesson 1 7. Whats the output rom the folowing code snippet? ‘System outprinth¢ (1 Pains 1s Mark for Review ‘The code will compile and print "2 “The code will compile and print "2 1") “The code will compile and print “The code does nat compile “The code will compile and print Incorrect Incorrect. Refer to Section 4 Lesson 4 8. Which combination of the following overload the Student constructor?(Choose Two) Mark for Review (1 Points (Choose al correct answers) public Object Stadontint xin 30 public Student) (1)protected int Student) publi vold Sudert(intx, Int yi public Studentintxint yi) (7) Incorrect Incorrct. Refer to Section 4 Lesson 1 98. Which two statements are access modifier keywords in Java?(Choose Two) Mark for Review (1) Points (Choose al comect answers) abstract final protected public) Incorrect Incorrect. Refer to Section 4 Lesson 1 410. What isthe output from the following code snippot? Sting str = String str2 ‘System .outpinth(strt oquals(st2) + "+ srt.equala(new Strng( helo); Mark for Reviow (1) Poines “The code will not compile “The code will compile and print "ve, false" (*) “The code will compile and print "also, ue" The code wil comple and print "ale, false” “The code will compile and print "rue, tus" Incorrect Incorrect. Refer to Section 4 Lesson 1 11, When you instant a subclass, the superclass constructor willbe also invoked. Trus or Fala? Mar for Review (1 Points Tne ()Correct Corct 42, Which statements are tre?(Choose Three) Mark for Review (1 Points (Choose al correct answers) You can use access mealies to contol which other classes ean call the constructor.) Since a constructor can not retum any valu, it should be declared as void Yu can declara mora than ene constructor ina class declaration *) constructor can nol be overloaded, Ina constucter, you can call a superclass constructor. (*) Correct Comet 13. Which ove following declarations are wrong?(Choose Three) Mark for Review (1) Points (Choose all comect answers) abstract nal class Hello (*) publi abstract class Stusont) protected prvate inte (*) abstract private void actX) (*) Incorrect Incorrect. R 14, Which statement is tue when run the following statement? 1. Sting str= nll 2 if (str != null) 88 (srlongth0) > 1)) 3, System.outprintn(“great that number 1) 4. ats it (sr = ul) & (stclongtn) <2) { 5. System.outprintin( les than number 2") 6.) Mark for Review (1 Points “The code compiles and wil throw an exception atin 2. “The code compiles and wil thraw an exception at ine 3. The code compiles and wil throw an exception at line 4. ()“The code compiles and wil throw an exception at ine S “The code does nat compile Correct Comect 16, What isthe output from the following code sripput? int inty, while <5) ye System outpinin(y); Mark for Review (1 Points “The code will not compile. () Incorrect Incorrect. Refer to Section 4 Lesson 1 Section 5 (Answer all questions in this section) 1. Immutable classes do allow instance variables to be changed by overiding methods, ‘True or false? Mark for Review (1 Points Tne False () Incorrect Incorect. Refer to Section 5 Lesson 2 2. Aninterface can implement methods. True or False? Mack for Review (1) Points Tae False () Incorrect Incorrect. Refer to Section § Lesson 25. Immutable classes can be subclasse, True or false? Mark for Review (1 Points Te False () Incorrect Ineortect. Refer to Section 5 Lesson 2. 4. Unittestng can help you isolate problem quickly. True or False? Mark for Review (1 Points Tne (+) False Correct Corect 5, The main purpose of unit esting i to vey that an individual ni (a class, n Java) is working correctly before itis combined with other components inthe system. True or false? Mark for Review (1) Points Tne (+) False 110 Section 6 Lesson 4 Incorrect Incorrect Rel 6. Which statement ists forthe class java.u.ArayList? Mark for Reviow (1 Points ‘The elements inthe collection are accessed using Key. ‘The elements inthe collection are ordered.) The elements inthe callton are immutable, “The elements inthe collection are synchronizes Incorrect Incorrect. Refer to Section § Lesson 4 7. Which ofthe flloing isthe corect way to throw cumstom Server Review (1) Points ception? Mark for thom ServerExcoptionthrows SorverExcopton tow new ServerException) (*) raise ServerException Correct Correct 8. What symbol(s) s usod o separate multiple exceptions in one catch slatemont? Mark for Review (1 Points Asingle verical bar () rs ) (equals equals) None, multiple exceptions cart be handled in one eatch statement Incorrect Incorrect. Refer to Section 5 Lesson 3. 8, Whatis the output rom the folowing code snippet? class Shapet publi vod pain({System out print"Shape")) class Circle extends Shapes Public void paint) throws Exception( ‘System out print(*Circle Publi static void main(Stingl] args ty{new Cirto( paint) cateh(Excoption o}{Systom out printh(‘Excoption" , ). Mark or Review (1) Points circle Shape Shapecircle Exception Compile als”) Incorrect Incorrect. Refer to Section 5 Lesson 3.40, Assorions are boolean statomonts to test and debug your programs, True or false? Mark for Review (1 Points Te (1) False Correct Comtoct 11, Which tree types of objects can be town using a throw statement? (Choose Thre for Review (1 Points Mark (Choose all correct answers) Error") Event Exception () Throwable () Object Incorrect Incorect, Refer to Section 5 Lesson 3, 12. The instanceat operator can find subclass objects when they are passed to method which oclare a superclass type parameter, True or false? Mark for Review (1) Points Te (*) False Correct Correct 13. The instanceof operator allows you to determine the type of an object. ‘True or false? Mark for Review (1 Points Tne (+) False Correct Correct14, Which one ofthe folowing would allow you to define the abstract class Animal. Mark for Review (1) Points public abstract Animal () publi Animal) public abstract Animal extends class) public abstract class Animal} (*) Incorrat Incorract. Refer to Section 6 Lesson 1 15, An abstract class can imalement ‘True or false? Mark for Review (1 Points Tw (1) False 1. Immutable classes can be subclassed, True or false? Mark for Review (1) Points Te False () Correct Comtect 2. Which one of the folowing would allow you to define an interface for Animal? Mark for Review (1 Points public class Animal) public Animal extends intetace public class Animal implements Interface {) public interface Animal ((*) Incorrect Incorract. Refer to Section § Lesson 2. 5. Immutable lasses do allow instance variables to be changed by overiding methods ‘True or false? Mark for Review (1 PointsTwo False () Correct Comet 4. The instanceof operator can find subclass objects when they are passed to method which clare a superlass type parameter True or alge? Mark for Review (1) Points Tne (+) False correct Correct 5. Which method wil force @ subclass to implementit? Mark for Reviow (1 Points ‘Abstract public void act) Public double act) Protected void ac(Strng name) State void aet{String name) ) Public native double act Correct Corect Section 5 (Answer all questions in this section) 1. What do Arrays and ArrayLists have in common? |. They both store data I. They can both be traversed in lops. IL Thay both can be dynamically re-sized during execution of @ program. Mark for Review (1 Points only only and it only) |. thand tt onlyNone of these Incorrect Incorrect. Rs 2. Reading great code is just as important ora programmer as reading great books is fora rite. True o false? Mark for Review (1 Points Two (1) False Correct Correct, 3. Unt testing can help you isolate problem quickly, True or False? Matk for Review (1 Points Tne) False Correct Corect 4. What Is te result rom creating te following ty-catch block? tay 2) catch (Exception e) { 3, catch (ArthmaticExceoption a) { 4.) Mark for Review (1) Points Compile fails at Line 3 *) Compile als at Line 2 “The code compiles Compile fails at Line 1 Incorrect Incorrect. Refer to Section § Lesson 3. 5, Whats one stop you must do to create your own exception? Mark for Review (1 Poinss Create new cass that implements ExceptionCreate @ new class that extends Exception. *) Exceptions cannot be created, They are only built into Java, Declare the primitive datatype Exception Correct Correct ‘Which statement added at tine one allows the code to compile and run? Ine one public class Te publ static vold main (Stingl args) { java.io Printer out = new java.io Printer (new java.io OutputStreamWter (System ou), tush ‘System.out printin( Java") , ), Mark for Reviow (1) Points No statement s needed. () Import java. io.OutoutStreamWriter include java.io: Import java io. Printer, Import java. Incorrect Incorrect. Refer to Section 5 Lesson 3. 7. This is corect syntax for catching an exception UryingutStream = "missinghile sx") catch(oxcoption e): ‘True or false? Mark for Review (1 Points Ts False () Incorrect Incorract. Refer to Section § Lesson 3. 8, Whatis exception handing? Mark for Review (1 Points It your program exits before you expect ito ‘When a fle fails to open.‘An ror that occurs against th flow of your program. ‘Aconsistent way of handing various ero. (+) Incorrect Incorrect. Refer to Section 5 Lesson 3. 98. Virtual method invocation requires thatthe superclass method is defined as which ofthe following? Mark for Review (1) Points [private final method ‘Adefaul final method ‘public final metho. publi static method. ‘A public method. (1) Incorrect Incorrect. Refer to Section 5 Lesson 1 40, An abstract clas can implemer ‘True or false? Mark for Review (1 Points Tne (+) False Correct Corect 11, Which fine contains an compilation error? Interace Shape Interface InnerShaps extends Shapo} class Circle implements Shapet } class InnerCirde extends Circle(> class Rectangle implements Shape() public class Tester ( PUBIC static void main(String] args) { Circle e= new Circle), InnerCircl ie = new lnnerCicl Reciangle rect = new Raciangla() System out.pin( instanceof InnerCiree; Line 4 System out pic instanceof Circe}; ine 2 System out pint(ect instanceof InnerGirle); Line 3 System outpriniect instanceof Shape); ‘Line 4 ) Mark for Review (1) Points Line 2Line 3() Line 4 Line 1 Correct Comoct 42, An abstract class can be instantiated True or false? Mark for Review (1) Points Te False (*) 13. in general, lasses can be made immutable by placing a final key word before the class keyword True or false? Mark for Review (1 Points False Tne) Correct Corect 14, The stato ofan object ferontates it rom other abjcts oft ‘True or False? Mark for Review (1 Points same clase Tae (1) False Correct Comect 415, Which one ofthe folowing would alow you to define an interface for Animal? Mark for Review (1 Points pubic interface Animal ((*) public class Animal implements Interface ()publi class Animal) publi Animal extends interface Correct Comoct ection 5 (Answer all questions in this section) 1, Whatis exception handing? Mark for Review (1 Points It your program exits before you expect ito, ‘consistent way of handing various eros, Wren a fe fails to open, ror that occurs agalnst the flow of your program. Correct Correct 2, Which statoments are ue when you compile and run this code. (Choose Two) 4. public class Test{ 2, publi static Sting sayHello(String name) throws Excepton( 3. name == null throw new Excopton) 4. return “Heo” + name: 5) 6 7. 8 8. Public static void main(Stingl args s9yHoli(‘Java") ) ) Mark for Review (1 Points (Choose al correct answers) can not create Exception object inthe Test Class. “The class Test compiles ne 6 contains a throws statement. publ static vod main(Stingl) args) tows Exception{(*) “The class Test compiles if line 7 is enclosed ina ty-catch block. ry{ sayHeo(‘Jav JeatehException €)9 (*) Compilation succeeds Incorrect Incorrect. Refer to Section 5 Lesson 3. 3. Assertions are optional ways to catch logic erors in code. True or false? Mark for Review (1 PointsTrue (1) False Correct Conoct 4. Assertions re boolean statements to test and debug your programs. True or flee? Mark for Review (1) Points Tne (+) False Incorrect Incorrect. Refer to Section § Lesson 3. 5. Whats the output rom the folowing cade snippet? publ static void main(Stringl argsy ty ‘Strings 0} ‘System.out prints) Jeateh(Excoption e) ‘Systom out prinin(“Excoption") JeatenNulPointerException 2 ‘System.out.printt'NullPointerExceptor"; ) Mack for Review (1 Points NulPointeException Compile fails”) Java Exception Incorrect Incorrect. R 110 Section 6 Lesson 3, 6, Aupward cast means al instance variables ofthe subclass 8 permanently lst tothe True or false? Mark for Review (1) Points Tae False () Incorrect Incorrect. Refer to Section 5 Lesson 17. The instanceof operator can find subclass objects when they are passed to method which ectare a superclass type parameter. True or false? Mark for Review (1 Points ‘Tw () False Correct Cotect 8. A downward cast of 8 superclass to subclass allows you to access a subclass specialized method call True or false? Mark for Review (1 Points Tw (1) False Correct Comoct 8. You can't downeast an object explicity because you must use vitual method invocation. True or false? Mark for Review (1) Points Twe False () Incorrect Incorrect. Refer to Section 5 Lesson 1 10, Unit tasting can help you isolate problem quickly. True or False? Mark fr Review (1 Points Tae (1) False Correct Cortect 11, Which ofthe following statements about arrays and ArayLiss in Java ara true? |. An Array has a fixed length, I, An Array ean grow and shvink dynamically as require, Il, An ArrayList can store muliple object types IV. Inan ArrayList you need to know the length and the curent numiber of elements stored, Mark for Review (1) Poinss 1 andi onlyHand IV only |e and i only ‘et andy None of these Incorrect Incorrect. Refer to Section 5 Lesson 4 12. Which statement is true forthe class java.ul ArrayList? Mark for Review (1) Poins “The elements inthe collection are synchronizes, ‘The elements inthe collection are accessed using ke. ‘The elemants inthe collection are ordered.) The elements inthe callecton are immutable, Incorrect Incorrect. Refer to Section 5 Lesson 4 13, Amethod with default access can be subclasses, True or flee? Mark for Review (1 Points Two False () Incorrect Incorrect. Refer to Section § Lesson 2. 14, Which two statements are equivalent to ine 2? (Choose Two) 1- pubic interface Account{ 2 int accountiD=100; 3.) Mark for Review (1 Points (Choose all correct answers) static int accountlD=100; (+) private int account Final int account 1005 ‘Abstract it aecounllO=100,Incorrect Incorrect. Refer to Section § Lesson 2 418, Classes define and implomont what? Mark for Reviow (1 Points ‘Al methods with implomertations Variables and methods (+) ‘Some methods with implementations {Al method defintions without any implementations Constants and all methods with Implementations 1. Virtual method invocation must be defined with the instanceof operator. ‘True or false? Mark for Review (1 Points Tne False () Incorrect Incorrect. Refer to Section § Lesson 1 2, Am abstract class can implement its methods. ‘True or false? Mark for Review (1 Points Two (1) False Correct Cotoct 3. You can't downcast an object explicitly because you must use vitual method invocation. True or false? Mark for Review (1) Points Tae False () Correct Correct4. Which mothod wil force a subclass fo Implomont i? Mark for Review (1) Poinss Abstract pubile void act): *) Protected void ac(Sirng name) Public double act): State void act(String name} Publicnatve double act) Correct Correct 5. Methods can not tow exceptions True or false? Mark for Review (1 Points Tae False (*) Incorrect Incorrect. Refer to Section Lesson 3. 6. In wnat order do multiple catch statements execute? Mark for Review (1) Points “The order thoy are declared in ( most spect st). *) They execute atthe same time, “The order they ara declared in (most general fis) None of them execute since you cannot have multiple catch statements, Incorrect Incorrect. Refer to Section § Lesson 3. 7, Which statements are rue when you compile and run this code, (Choose Two) 1. public 2 publi static Sting sayHello(String name) throws Excepton( 3, ifloame == null) hrow new Exception 4. return “Hato” + name: 5) 6. public static void main(Stingl args) 7 8 8 3 Test soyHello( Java ) ) Mark for Review (1 Points {Choose all correct answers)Test Class can not create Exception object in Compilation succoeds The clase Test compiles fine 6 contains a tows statement, publ slate void main(Stingl) args) tows Exception (*) Te clase Test compiles ine 7 i enclosed ina try-cateh block. ty{ sayHel(‘Java") Jeateh(Exception 0X) (*) Correct Cortect 8, This s correct syntax for catching an exception tryingutStream catch(exception ‘True or false? Mark for Review (1 Points *missingfile Ts False (*) Correct Cortect 8, Mutiple exceptions can be caught in one eatch statement. True or false? Mark for Review (1 Points Tw (1) False Correct Comet 10. You can only implement one interface in a cass. True or False? Mak for Review (1 Poinss Tae False () Incorrect Incorrect. Refer to Section § Lesson 2. 11, Immutable classes can be subclassed, ‘rus or false? Mark for Review (1 PointsTwo False () Correct Coroct 12, Which one ofthe folowing would alow you te define an interface for Animal? Mark for Review (1) Points public class Animal ) public Animal extends nt 20 public lass Animal imploments Interface {) public interface Animal (+) Correct Correct 13. Which ofthe folowing statements i false? Matkfor Review (1) Points ‘An ArrayList has a fixe length (*) ‘An AcrayList can store multiple object types. ‘An ArrayList can grow and shrink dynamically 28 requited. In an Array you need to know the length and the curtent number of elements stored Incorrect Incorrect. Refer to Section § Lesson 4 Test: Java Programming Midterm Exam and question scores below. An asterisk (*) indicates a correct Review your answers, feedbac Section 1 (Answer all questions in this section) 1. The function of Garbage Collection in Java is: Mark for Review (1) Points “The JVM uses GC to clear the program output. “The JVM GC deletes all unused Java fles onthe systom. Memory occupied by objects with no reference is automatically reclaimed for reuse. (*)‘As a Java programmer, we have to call the GC function specially inorder to manage the Java, Memary, Correct Cotect 2. Which ofthe following allows the programmer to destroy an object referenced by x? Mark for Review (1) Points xr0movel) xfnaiz() xlete( Only the garbage collection system can destroy an abject. (*) Correct Correct 3. Gwen the folowing output from the Minor 6c [PYoungGen: 9200K->1008K(9218K)} 9980K->3251K(19458K),0.0045753 secs] [Timescuser=0.03 sy$=0.03,real=0.00 secs \Whion ofthe follwing statements is TRUE? Mark for Reviow (1) Poinss “The pause ime spentin BC is 0.03, “The size ofthe entire heap is 19456 (*) “Ths is a major garbage callcton process. The size oft tenured space is 19458 Correct Comoct 4. Java allows the same Jay Review (1) Pints program to be executed on multiple operating systems. Mark for Tne (+) False correct Correct 5, Which ofthe following statements describe the Java programming language? Mark for Review (1 PointsJava is a high-level programming language, “The Java programming language includes a garbage collection feature. Java isan object orented programming language. Al ofthe above (*) Correct Correct age 1 of 10 Next Summary Test: Java Programming Midterm Exam Roviow your answers, feadback, and question scores below. An asterisk ("indicates a correct Section 1 (Answer all questions in this section) 5, Given the java snippet below public class Foot ble void testFoo() int y=100; , ) Which ofthe following statomonts is TRUE? Mark for Review (1) Points Compile error, a the variable x snot inaized Variable x resides in the stack area, and variable y resides in the heap of the JVM. ‘Variable x resides inthe heap area, and variable y resides in the stack af the JVM (*) Variable x stays inthe heap area, and variable y resides inthe method arca of the JVM. Correct Cortect Section 2 (Answer all questions in this section) 7. The javac command can be used to Gisplay native code in Java Mark for Reviow (1) Points Twe False ()Correct Corect 8. Which ofthe following commands can be used to translate Java Source code into bytecode? Mark for Review (1 Points java javae ¢) job jstat Correct Correct 98, Which ofthe following statements fs NOT TRUE forthe je command? Mark for Review (1 Points jb can display the source code. ab can set the break pont forthe program. Job can dump the stack of the current thread. jb can track the GC activity of re program. (*) Correct Correct 410. Like inthe Java source cade fle, one Java class file can contain mulipe class definons, Mark for Review (1 Points Ts False (*) Correct Cortect Previous Page 2 of 10 Next Summary Test: Java Programming Midterm Exam Review your answers, feedback, and question scores below, An asterisk (*) indicates a comet Section 2 (Answer all questions in this section)‘1. Which structure n the Java cass fle cantains te Ine number information fr the original source fle? Mark for Review (1 Points method info) this_ class fled_nfo pinto Correct Correct 12, The attsbute Mark for Review (1 Points s_countilem indicates how many atibules ae contained within a mathos. Te (1) False Correct Comtoct Section 3 (Answer all questions in this section) 413, Which of the folowing opcode instructions would add 2 Integer variables? Mark for Review (1 Points ade ads Tadd (+) Incorrect Incorrect. Refer to Section 2 Lesson 1 14, Choose which opcode is used o push an int constant 6 onto the operand slack, Mark for Review (1 Points ieonst_$ ¢) iesioad_s laloas_§ lines Correct Comet 15. opcode invokespecial is used to invoke an instance inilzation method. Mark for Review (1 Points Tne (1) False 16. Which ofthe folowing is NOT a java classloader? Mark for Review (1 Points verification class loader () ‘application class loader bootstrap classloader extension classloader Correct Comtct 17. The Java developer can dafine @ numberof addtional or custom classloadrs. Mark for Review (1) Points Tne (*) False Correct Correct 18, Which ofthe fatowing exceptions is thrown by the loadClass() method of ClassLoader class? Mark for Review (1 Points loBxception systemExcoption ClassFormattorCassNotFoundException *) Correct Corect Section 4 (@nswer all questions in this section) 48, Which three are valid declarations fo a float value? (Choose Three) Mark for Roviow (1 Points (Choose al correct answers) float float = 0x345; (*) float = 3.01; float f= 2.08 (7) float f= 1.0; Correct Comect 20, What is the final value of result rom the flowing code snippet? imi= ts int id= new int (3 Int rout = resull= rosull+ i; Mark for Review (1 Points “The code will compile, result has the value of © Te code will compile, result has the value of 1 (") “The code will not compile, resuithas the value of 2 “The code will compile, result has the value of 2 ‘An exception i thrown. Correct Corect Previous Page 4 of 10 Next Summary Test: Java Programming Midterm ExamReview your answors, feedback, and question scores below. An astorisk (*) indicates a correct Section 4 (Answer all questions in ths section) 21. What isthe output from the following code srippot? String strt= "ava" Sivng str2-new Sting java" ‘System out printing st ‘System out pint st Mark for Review (1 Pines “The code does not compile “The code will compile and print "rus fase “The code will compile and print "alse tue" (*) “The code will compile and print "ase false” “The code will compile and print "rue trust Correct Correct 22, What isthe output from the fllowing cade srippot? Int myaray=(1.23:4.5) Int sum=0; for(int x: myaeray) ‘System .outprnthy’sum= "+ sum): Mark for Reviow (1) Points “The code will not compile 150) 20 Correct Correct 23, Examine the folowing Classes: Stugent and TesiStudent \Whatis th output rom the prints stalament in TestStudent? public class Student Privat int student = 0 public Student stugentides; public static int gotStudentd(return studontld; ) publi class TestStudent publ static void main(Stingl] args) { Sludent 1 = new Student Student 2 = new Student Sludent $3 = new Student System out prindn Student gotStudente)) ). Mark or Review (1) Points No output. Compilation of TastStudent falls (*) “TesiStudent wil hrow an exception Correct Correct 24. Which ove following declarations are wrong?(Ghoose Three) Mark for Review (1 Points (Choose al comect answers) abstract private void act) publ abstract clas Stusont) protected prvate inte (*) abstract nal class Hallod (*) Correct Corect 25, Which ofthe folowing types are primitive datatypes? (Choose Two) Mark for Review (1) Points (Choose all correct answers) String boolean (*) ouble IntegerCorrect Comect Previous Page 6 of 10 Next Summary Test: Java Programming Midterm Exam Roviow your answors, feedback, and question scores below. An asterisk ("indicates a correct Section 5 (Answer all questions in this section) 26, Immutable classes do allow instance variables to be changed by overriding methods. True or false? Mark for Review (1) Points Tw False () Correct Correct 27. You can erly implement one interface in a cass. True or False? Mark for Review (1) Points Ts False () Correct Corect 28, Inerfaces define what? Mark for Review (1 Points Constants and all methods with implementations ‘Some methods with implementations [Al mathad defintions without any implementations (*) [Al methods with implomentations Variables and methoas Correct Conect 28, Maseling classes fora business problem requires understanding ofthe business nat Java. True or false? Mark for Review (1) PointsTw False () Correct Corect 80, Classes define and implomont what? Mark for Review (1) Pains ‘Some methods with implementations Constants and al methods with implementations [Al mathads with implamentations {Al method defintions without any Implementations Variables and methoss (*) Correct Correct Previous Page 6 of 10 Next Summary Test: Java Programming Midterm Exam Review your answers, feedback, and question scores below. An asterisk *) indicates a correct Section 5 (Answer all questions in ths section) 31, An interface can implement mathods. ‘True or False? Mark for Review (1 Points Ts False () Correct Comtect 32, When line 10 is executed, which method willbe called? 1 class Account ( 2 public void depositint at, int amt) () 3 public void depositint amt} 4) 5 public lass CrectAccount extends Account { 6 public voia deposit) () 7 public void depositin at) 8 public state vod main’Sting args {9 Account account = new CreditAceount)10 account deposit) 1} 12) Mark for Review (1 Points line 7) line 2 ines line 6 Correct Correct 33, You can always upcast a subclass to an interface provided you dont need to access any members ofthe concrete class True or false? Mark for Review (1 Points Tne) False Correct Correct 34, Which two ofthe following statements ae true? (Choose Two) Mark for Review (1 Points (Choose al correct answers) [An abstract class must contain abstrt method, [An abstract class can define constructor. (*) ‘An abstract class can ereate subclass and be constructed [An abstract class must be dined by using the abstract keyword. (*) Correct Cortct 835. An abstract clas can implement its methods True or false? Mark for Review (1) Points we) FalseCorrect Cottct Previous Page 7 of 10 Next Summary Test: Java Programming Midterm Exam Roviow your answors, feedback, and question scores below. An asterisk (*) indicates a correct Section 5 (answer questions in tis secton) 36, Virtual method invocation must be defined withthe instanceof operator. True or false? Mark for Review (1) Points Te False (*) Correct Correct 37. You cant downcast an object explicitly because you must use virtual method invacation True or false? Mark for Review (1) Points Ts False () Correct Comect 238, Which ofthe folowing is the correct way to row cumslam ServerException?” Mark for Review (1 Points teow ServerExceaption throws ServerExcapton throw new ServerException()(*) raise ServerExcoption Correct Correct 38, When will a fnally statement be executed? Mark for Review (1 Points ‘Always, no matter fan exception is thrown oF not (7)Onl fan exception is nt thrown Never itis there for visual purposes, Only if mliple exceptions are caught and town, Ony fan exception is thrown, Incorrect Incorract. Refer to Section § Lesson 3 40. Whats the output from the folowing code snippet? publ static void main(Stingl args te Sting] sna {0} ‘System.outprint(sf0) JeatehyException e) ‘System.outprint("Exception"); JeatenNulPointarException 6 ‘System out prininNullPoiterExcepton”) ) Mack for Review (1) Points Exception NulPointerException Compile als") Java Correct Corect Previous Page 8 of 10 Next Summary Test: Java Programming Midterm Exam Roviow your answars, feedback, and question scores below. An asterisk ("indicates a correct Section 5 (Answer all questions in his section) ‘41. Which statements are true when you compile and run ths code (Choose Two) public class Tost Public static Sting sayHell( String nama) throws Excepton( {ame == nul throw new Excepton() return Holo” + name public static void main(Stingl] args sayHello(‘Java") ) 1 2 3 4 5) 6 7. 8 8.) Mark for Review(1 Points (Choose al correct answers) ‘The clase Test compiles if ne 7 s enclosed ina try-catch block. ry{ satel Java") Jeateh(Exception eX (*) Compilation succoeds an not create Excoption object inthe Test Class. “The class Test compiles ne 6 contains a throws statement. publ static void main(Stingll 193) throws Exception (*) Correct Correct 42. The finally clause only executes when an exception isnot caught and thrown. True or false? Mark for Review (1 Points we False (*) Correct Correct 43. In what order do multple catch statements execute? Mark for Review (1) Points “The order thoy aro declarad in ( most specific fst). (*) They all execute atthe same ume, “The order they are declared in (most general fs) None of them execute since you cannot have multiple catch statements, Correct Correct 44, Mathods can nol throw exceptions. ‘True or false? Mark for Review (1 Points Te Fatse () Correct Comoct45. Whal do Arrays and AvayLists have in common? |. They oth store data, 1. They can both be traversed in loops. ‘hoy both can be dynamically re-sized during execution of a program. Mark for Review (1 Pins only ony land only) and th only None of these Correct Correct Previous Page 9 of 10 Next Summary Test: Java Programming Mitorm Exam Roviow your answors, feodback, and question scores below. An astorisk ("indicates a correct Section 5 (Answer all questions in this section) 48. The main purpose of uni testing is to verty that an individual unit (a clas, in ava) is working correctly before it's combined with other components inthe system. True or fas? Mark for Reviow (1 Points To) False Correct Cottct 47. Whyis ithlpfl for new programmers to read pre-written code?(Choose Two) Mark for Review (1) Points {Choose all corect answers) Itis not helpful to reac code writin by other programmers. Learn new programming techniques.) Understand code writen by other programmers *)Meet new programmers. Correct Corect 48, Which ofthe folowing statements is false? Mark for Review (1) Points An ArrayList has a fixe length. *) ‘An ArrayList can store multiple object types. In an Array you need to know the length and the current number af elements stored ‘An AcrayList can grow and shrink dynamically as requte. Correct Comet 49, Which ofthe folowing statements about unit testing sfare true |. Wher all unit tests succeed, you can have high confidence your code is soi I. fa unittest fais, you donst proceed until the codes fixed and the test succeeds. I Unit testing can help developer fine problems early in the development cyl Mark for Review (1) Points only | and it only Wand i enty¢) hetl-and it None of these. Correct Correct 50, Which ofthe folowing statements about arays and ArrayList in Java are tre? |. An Array has a fixed length I, An Array can grow and shrink dynamically as require, Ii, An ArrayList can store muliple object types IV. nan ArrayList you need to know the lorgth and the curent numibar of elaments stored, Mark for Review (1 Points 1 and il only Wand 'V only 1th and it only‘th and iv None of these 14. Why ist helpful for new programmers to read pre-wrten code7(Choose Two) Mark for Review (1)Poinss (Choose all comect answers) Loam now programming techniques. (") Meet new programmers. Understand code written by other programmers Itis not helpful fo reac code written by other programmers Incorrect Incorrect. Refer ta Section § Lesson 4. 16. Which of the fotowing statements about inhertance is false? Mark for Review (1) Points ‘Asubciass inonis athe members (elds, methods, and nested classes) fom its superciass. Inheritance allows you to ruse the fields and methods ofthe super class without having to write thom yourset Invertance allows you to minimize the amount of duplicate code in an application by sharing ‘common code among several subclasses. “Through inhertance, a parent cass is a more specialized form ofthe child class. (*) Incorrect Incorrect. Refer to Section § Lesson 4 Section 6 (Answer all questions in this section) 1. ALinkedlistis a type of Stack ‘True or false? Mark for Review (1 Points Tw () False Correct Correct 2. Which ofthe following is Ist of elements that havea fst ast aut ordering. Mark for Review (1) Poinssarrays Hashttape Enums Stacks (1) Incorrect Incorrect. Refer to Section 6 Lesson 3 3. AHashMap can only store Sting types. ‘True or false? Mark for Review (1 Points Te False (*) Incorrect Incorract. Refer ta Section 6 Lesson 3. 4. Which of the folowing corecty defines a queue? Mark for Review (1) Points Alls of elements wih a fst in last out order. Alls of elements with fst infest out order. *) It is @ keyword in Java that restiet the use ofthe cade to local users only. ‘Something tat enables you to create a gonerc class without spacing a lype betweon angle brackets ©. Incorrct Incorract. Refer to Section 6 Lasson 3. 5, Which ine contains an compilation error? interface Shape ‘lass Circle implements Shape) public class Test ble static void main(String] args) { Lists = new Arrays); f Line 4 Ustle = now ArrayList)! Line 2 Circle ¢= new Circle Is.adae): Line le-ada): Line ) Mark or Review (1 PointsLine 2 Line 4 Line 1 Line 3) Incorrect Incorrect. Refer to Section 6 Lesson 2. 6. Which class an ordered calecton that may contain duplicates? Mark for Reviow (1 Points rst) set array Incorrect Incorrect. Refer to Section 6 Lesson 2. 7. The fallowing cade is valid when working with the Collection Interface Collection collection = new Calecton()e; True or false? Mark for Review (1 Points Two False (*) Correct Corect 8. Whats the output rom the folowing cade snippet? publi static void main(Strngf] arasi List yew ArrayList) asd) Nasa) prin ) publi static voi prints Uist { for (Number n= ist) Systemoutprint(a ), Mark for Review (1 Points “The code will not compile.120 Incorrect Incorrect. Refer to Section 6 Lesson 1 9. <7 extends Animal >is an example ofa bounded generic wildcara True or False? Mak for Review (1) Points Tne (+) False correct Comect 10, What isthe correct defintion of Enumeration (or enum}? Mark for Review (1) Points Code that infialzes an ArayList AAlistof elements that is dynamically stored ‘Abounded generic class ‘Akeyword that speciies a class whose objects are defined inside the class. (*) Incorrect Incorract. Refer to Section 6 Lesson 1 11, Which of the folowing would inialze a generic class “Cel using a Sting ype? 1.Coll cet = new Celi 1. Colt ea i, Cale Mark for Review (1) Pines Hand) only Wand only ony Incorrect Incorrect. Refer to Section 6 Lesson 142. Why might a sequental search be ineficient? Mark for Review (1) Points Iutiizes the “vide and conquer* method, which makes the algorithm more error prone. It oquires incrementing through the entice array in the worst case, which is ineicient on large ata ses, () IRinvoWves looping through the array multiple times before finding the value, which is inefficient on arge datasets. Itis never inefcent, Incorrect Incorract. Refer to Section 6 Lesson 4 13, Which ofthe flowing sorting algorithms uiizes a "vida and conquer" technique te sort arrays with optimal speed? Mark for Review (1 Points Sequential Search Merge Sort (*) Selection Sort Binary Search Allof he above Incorrect Incorrect. Refer to Section 6 Lesson 4 14, Bubble Sorts a sorting algorthm that involves swapping the smallest value into the fret index, fing the next smallest value and swapping tint the next index and so on unl the array is sorted. True or false? Mark for Review (1) Points Te False (*) Incorrect Incorrect. Refer to Section 6 Lesson 4 15. A sequential search isan eration through the array that stops a he index where the Gosivedolamant s found. ‘True or false? Mark for Review (1) Pins Tne)False Correct Correct Section 6 (Answer all questions in ths section) 41, Which ine contains an compilation errr? Interace Shape class Cite implements Shapot} public class Test public static void main(Stringl args) { Listis = now Arrays)! Lint Liste = new ArrayList)! Line 2 Circle ¢= new Circle Issa); Line lecada(e): Line ) Mark for Review (1 Points Line 3) Line 4 Line 1 Line 2 Correct Comet 2, Which ofthese could be a set? Why? Mark for Reviow (1 Points (1, 12,22, 305, 26) bacause a set may contain duplicates and alls elements are ofthe same ‘ype. (Apple 1, “Carr, 2) because it records the index ofthe elements with following integers. (1, 2,5, 178,259} because it contains no duplicates and alls elements are ofthe same type. ° [Al of he above are sots because they are collections that can be made fo fi any of the choices. Incorrect Incorrect. Refer to Section 6 Lesson 2. 53, Which code inserted into the code below guarantees that the program will output [1,2]? Innpot java ut public elass Example( Public static void main(String] args insert code here setadel2)sotadatt) System outprntn(set } Mark for Review (1) Pins Set set» new SortedSet) eet) (*) ‘Sot sot = now LinkedHashSet); Set set = new HashSet() List set = new Sorte ist) Incorrect Incorrect. Refer to Section 6 Lesson 2. 4. Big-0 Notation is used in Computer Science to describe the performance of Sorts and ‘Searches on arrays. True o false? Mark for Review (1 Poinss Tne (1) False Correct Comtect 5, Selection sots efficient for large array. ‘True or false? Mark for Review (1 Points Te False () Incorrect Incortect. Refer to Section 6 Lesson 4 6, Which ofthe following sorting algorithms utilizes a “divide and conquer technique to sort arrays with optimal speed? Mark for Review (1 Points Sequential Search Merge Sort (*) Selection Sort Binary SearchAll ofthe above Incorrect Incorrect. Refer to Section 6 Leeson 4 7. A sequential search isan iertion through the array that stops a the index where the desired alamant is found ‘True or false? Mark for Review (1 Points Te (1) False Correct Corect 8. Enumeration (enums) ar useful for storing data : Mark for Review (1 Poinss \When you know al ofthe possibilities ofthe class (*) ‘When the class s constantly changing When the class isa subclass of Object. You cannot store data In an enum Incorrect Incorrect. Refer to Section 6 Lesson 4 8, A generic class increases the risk of runtime class conversion exceptions. ‘True of False? Mack for Review (1) Points Tue False () Correct Correct 10. Generic methods are required to be deca True or False? Mark for Review (1 Points static. Tae False ()Correct Comet 11. The following code will compile. True or False? class Nede implaments Comparablo{ ‘public int compareTa(T abjetum 1) ) class Test{ ‘public state void main(Stingll args} Node no=new Node<>() ‘Comparable com=ne ) Mark for Review (1 Points Tae (1) False Correct Comet 412, Which scenario best describes a stack? Mark for Review (1)Poinss ‘pile of pancakes with which you add some tothe top and remove them one by one from the top tothe bottom. ¢*) ‘Arow of books that you can take out of only the midle ofthe books fst and work your way outward toward ether edge. Aline at the grocery store where the fst person inte lines the frst person to leave, All ofthe above describe a stack Incorrect Incorrect. Refer ta Section 6 Lesson 3. 13, Where you enqueue an element inthe Ist? Mark for Review (1 Points adds it te end ofthe Ht (*) ‘adds ito the star oft ist removes irom the front of thelist removes it fom the end ofthe list Incorrect Incorrct. Refer to Section 6 Lesson 3. 14, ALinkedList is a type of Stack,True or false? Mark for Review (1) Points Twe False Correct Correct 15, A LinkedList sa it of elements tat is dynamically stored ‘True or false? Mark for Review (1 Points Tne (+) False Correct Comect 1, Allclasses can by subclassed, Mark for Review (1) Pins Twe False () 5. Whats special about including a resource ina try statoment?(Choose Two) Mark fr Review (1 Points (Choose all correct answers) “The resources wil aut-cose.(*) or wil be thrown if the resources does nat apen.(*) “The program wil fall the resource does not open 6, Why should you not use assertions to check parameters? Mark for Review (1 Pines [Assertions can be disabled a run ime which may cause unexpected resuls in your assertions. ° Not allmethods have parameters, therefore assertions should never be used on parameters Itis hard o assume expected values fr parameters. Assertions do nat work on parameters 15. When an objectis able to pass on its state and behaviors tots children, this is called: Mark for Review (1 PoinssInbertance (*) Encapsulation Polymorphism Isolation Pctas by kato reso 3t 727 PM 97 comments: 38 Unknown Dacember 21,2018 at 5:41AM ‘Seton & (answer at questions inthis secon) 1 An example of an upper bounded wildcards pera) Arrytist eraytist, erate 2.cnumeraton (nuns) are useful fr sorng data men the cass is constantyenanging When you know al ofthe posses of th class (*) nen the case ea subclass of Object. ‘You cannot store tan an erm ‘3. When woul an enum (er enumerator) be uses? ‘nen you already know a te possi for objects of tat lass.) When you wisn to remove data rom memory. men you with to nitze a Hash When you want to be able to cteate any number ofebects of tha ass 4. Enumeration (enum) must be declared in thelr oan else.we Faso () ‘S.8ubole Sort is 2 sotng algrihm that volves swapping the smal vais Into te rat indo, {ining the nex smallest vale and swapping ilo the nex index and so on ui the aay sorte, Tue Fale ¢) ‘5.0 ofthe following best describes ldcographicl order? ‘Avon based onthe ASC vale of characters) “The order of nda aftr an aay has been sorte. [simple sorting alporitm thats ineficient on large arrays, ‘complex sottng sgt that aeent on age ays "7.8g-0 Notation is used in Computer Scisnco to desesbo tho performance of Soris and Searches, on arays. Tre o fale? Tue) £8. Which of tho folowing sorting algorithms uses a vide and conquer” tochniqu to ort arrays vith pti speed? ‘Sequontal Search Merge Sort (*) ‘Selection Sort Binary Soarch| Aloe above 8.1hich of tho flowing comocty adds “Cabbage tothe ArayListvogolbles?vegetables] = "Cabbage vogotabes += "Cabbage vogotabas gt'Caboage vegetables add'Cabbage) () ‘0:4 intartace fom the oot of colections haar? javaustap ssvauittist Java.tlCatecton ava. Cottons 1. What isa st? ‘Acolecton of elements tht does nt contain duplestes (7) ‘Akeywordin Java hat iniaizes an Arayist ‘Something that erable you to crate racks © gonorc lass without speciying @ type between angle ‘Acollacton of laments that contain dusetes, 12. To alow aur asses to havea natural order we could implamant ine Comparable interface, “True or fale? Tuo ¢) Fale *S:¥ne ofthe folowing sti of elements that have oes lst at ordering. Stacks () Hasta ays“Un can a LinkedList be consderes a stack anda queue?(Chocee Three) ‘Because you can add elements othe end of (*) ‘Because you can not add element tothe begining oft ‘ocause you can remove elements om the on of.) Because you can remove elements fom the bepinning fit () ‘6:heneoonaro best desrbes a stack? ‘ple of paneakes wth which you ade some to the lop an remove them ane by one rm te op tothe botom. ¢) ‘A row of books that you can tako out of only the middle of the books fest and work your way ‘utara towara eter edge, ‘Aine a the grocery sore where the fst person nth ine isthe fst person to ‘A of te above describe a stack, Reply Replies ee ernest tes 16. A gonaric class is type of class that associates one or more nanspocc Java typos wits it Tre or Fes? Te () Fatee 17.The bal peting 200 is wing a program to be able to eller group animals avian to species to beter kaop ack of whal animals they have Wich of the folowing correct detines collection ts may eoale these types of groupings fr each specie at the 200? publi ass animalGotecton{) ¢) Publi ass snimalCotecton/nimaype 1) (F) publi ass srimalCoteetion 2) publi ass snimelCotectonanimeltype114 Whatis the repult fom the following code erin? publi tt void main(String 2s) ( LUst st = now Aras) stdin Gur) 2 acainew Integer) System out pinth(at2.200) “The code il not comple, 20) 1The Compares interface defines the comparaTa method, “nie orflee? Tree) False 20.¥ich statomons, inserted Wat Hn 2, wil ensure thatthe code snippet wil comple ccs (Choose Two}: | publ sal old main (Stingers) { 2uinsar code here 3 spur StudontD”, 125; 4) (Choose al corset anew) ap s= new SortesMap Sortattap 8 now TreeMap(() ArrayList = new ray HashMap 2= naw Hasboap; 21.Wrich sth corect way to ntaize a HashSot? HashSetcassMates = row Masha) ¢) Hashset( ‘Sting classMales = now Strat close = now HeshSeStina8 It enables you to create @ generic dk brackets <> without epeciying @ type bedween angle Its an intrface in ho java. package thats used to dein a group of objects. *) Its specal ype of lass thatle associat wih ane or more non-speeed Java ype Its subclass of st 25:Which of he following Is sorting algorthm that volves repeatedly incrementing trough he aray and swapping 2 adjacent values fey are he wrong ord uns ll Merge Son faunble Sot) Binary Search Sequential Searcn Selecton Sor ply Unknown December 2, 2018 at 6:38AM Section 7 (Answer ai quastons inthis section) Whats the comet explanation of when this code i vets tue? ‘stu strmatchos[0-3]8, "7; Mark for Review (Points ‘Any timo thats contains two dt. ‘Ay te hat str cntaine a sequence fit. (7) ‘Ay time hast has between zoo an rine charactors fosowed by 26, ‘Anytime se contains a6 Aways. 2. Which ofthe folowing methods forthe Sting class take a regular expression as a parameter ‘and retums true # he sting matches the exreason? Mark or Review (Points comparee(Sting regex) ‘uals Sting regex)smatehasiSting 6903) ‘ceualsgnoreCase(Sting regex) Incomact,Reer to Section 5 Lesson 2, ‘2. Whats the functon of the asterisk () in raga expressions? Mark for Review (nyPois Indicates thatthe preceding character may occur 0 0 1 tes ina proper match preceding character may occu 0 or mor times in proper mah.) “Th ssterek has no funtion in roguar expressions Indeates hat the preceding eharsctor may cccu 1 or mote times In a proper mate, Income, Refer to Secon 3 Lesson2 4. Which of he foonng coeety tings Matcher? Mark for Review (Pains ‘Arogular expression symbol hat represents any charactr. Amneod of ding a sting into aa of sub-tings. ‘Adlassin ho java.uragex package tat sors the format of arogular expression ‘class in ho jva.egex package that sores the matches between apatlom and m atin.) ‘corset '5, Mather nasa tnd method that chacks the specified patton exists as asub-shing of he sting being matched “True or alee? Mark for Review (Poi Tuo) Fate ‘corect 6. Which fhe folowing corsety defines Patt? Mark or Reviow (Peis ‘Aregularexpresion symbol hat represents any character. -Amethod of diding a sting into aso of sub-stings. ‘Actas nthe java.uregex package that sors the format fa regular expression. (7) ‘clas inthe java. regex package that stores matches.Incorec. Reet to Secon Lesson 2. 7. Which ofthe following corset intalzes @ Matcher m for Patiern p and Sting st? Mark for Roviow (Peis ow Matcher Matcher m = new Malcherip Matcher m matches) Incomoct,Roer to Secon 3 Lesson 2, '.Alinear ecusionraques the method to cll which dection? Mark for Ravaw (Pons Forward Bacon) oth formar and backward None oft above Incomec, Refer to Secon 3 Lesson 9, Which ease doos a recursive method cal ns? Mark or Review Poi Convergence Case ane Cane ‘Base Case (*) None af te above ‘corect +0. Anon-tnoa ecursive method it ass expensive than 2 near recursive method. Tue ofl? Mark for Ravew (Pains we False) oplyopis Q Perr eters essa 11. A nomtinaar recursive method cals how mary copie of se inthe ocusive case? ark for Review (1) Points 2ormore() onset 12. Using te FOR loop metrod of incrementing trough a Sting is benef # you doses: (Choose all hat app) Mark for Raview (Poms (Choose all corset answers) Parse the Sting.) Read the Sting backwards (fom ls lemon fo fst elon. (1) Search ora specie character o Sting inside af the Sting. () You dont use a FOR oop wis Stings Ineomact. Reet Section 3 Lesson 1 13, Spl s a metiod for Stings that parses a sing by a spocted charac, of Lunspectid, by spaces, anaretums the parse elemants in an aay af Stings “rue or fale? Mark or Review (1 Points tne Fake) cone 14. Whiea of the lowing comely insazes a StingBulder? Mark for Review (Points StingBulder sb = “Ths is my Sting Buide’ SeengBullder sb = StingBuler(600) StingBulder sb = new Stenger) None ofthe above, Income, Refer Section 3 Lesson 1 15. Whi of he following are tue about the method spe? Mark for Rewew(Points (Choose all corset answers) Iteotums an ara of stings.) Itean be used wih 2 sting a a parameter.) Its ofa, wit no speci parameter. is parsing by spares, ean be used with arogular expression as aprametr.) Income. Refer to Section 9 Leeson 1 1. Matener has fod method that chock if the speci patom exists as 9 sub-tng othe sting being matched, Tr o se? Mark or Review (Poms Tue) Fate Income. Refer to Section 9 Lesson 2, 2, Whies ofthe folowing methods for he Sng cass take a regular exoresson a8 & paramos and rors tue We sting matches te expression? Mark fr Review (1) Poms compareTo(Sting r2988) ‘matchesSting regex) (1) tng e923) ualslgnoreGase( Sting regex) Income. Refer to Saetin 3 Lesson 2. Reply ‘Unknown Dacember 21,2078 at 641 AM 23. Which of the follwing does not conecty match the regular expression symbol HS proper ‘uncon? Mark or Review (Pais “(a maans ore mus be x ocertoncs of the proceding character in the sing tobe match “7 means there may be zero or one oocurences of the preceaing character inthe ating to be a sate “+ moans there may be zor or more eccurrencas of the precoding charactor nthe sing Yo bo a mater) *(a)" moans thote may be x a more occurrences of the precessng charactr inthe sting o bea sate,“teyf" mesns thre may be betwaan x and y occurences ofthe preceding character in he sting tobe aie, Inoomec. Refer to Secon 3 Lesson 2 4. Consider designing program that organizes your corel alphabetcaly by last name, then by ‘rst name, Oddly all of your contacts fst an last names are exalt long. Wich ofthe flowing segments of code esabshos a Patter namePatim with a group for {rst rare ar a grup for holst name conscering that he sting contactsNare Is always in the format atName_frsiname? Mark fer Review (Peis Pattern namePatem = Pater comple" )((5)": C1 attrn namoPatom = Pato compile as Pater namePaton = new Paterna. s)} Pattern namePatter = new Pater Mane of te above, Income, Refer to Secon 3 Lesson 2, '5, The falloning code conotyintazes a pattern wih the regular expression 0-82}(0-9]2910- aren: Pattern date = Pater compl 1-94240-92)(0-9}2)" “Tru or fale? Mark for Roviow (Points rue) Foo Income, Refer to Seton 3 Lesson 2, 6. na regular expression, (and fx.) cepresent te ‘eur or mare te o crate a match “True or fale? Mark for Review (Peis we Faso ¢) ‘corect 7. What's the corct explanation of whon this codo wil rotum tue? ‘elum stmachest 0-96). Mark for Review (Pais ‘Ay time that str costars two dots. ‘Any imo thats contains a sequonce of 8 gts (7)‘Any ta hat str has between zero a nine charactars ftom by a8. Any ime contains a, Aways. Income. Refer to Secon 3 Lesson 2. '8, Using the FOR loop mato of incrementing tough & Sting fs ben {Choose al thal appy) Mark for Revow Poi foal you sie to: {Choose a conc answers) ‘Soares ora spacife character oF Sig inside ofthe Sting.) arse ne Sting.) ‘Yu dont use a FOR lop wit Stings ‘Road he Sting backwards am lst elemento fest element.) Income, Refer o Section 3 Lesson 8, Which of the ftowing ae ue about th metrod split? Mark or Revow Points (Choose a corect answers) es cota, wih no spoctod paraetar,is parsing by spaces. Ihean be used wt 9 gular expression asa prametr() Ihean be usod wt a sting as a parameter. (+ Ieretums an ary o stings.) Income. Refer to Secon 3 Lessons 10, Identity the method, of those fated Below, that it not avaiable fo bol StingBuliers and ‘Srna? Mark for Review (Pains lena IndexoH Seng sr) charAintndex) oll start, nt on) Income, Refer to Sechon 3 Lasson 1 ReplyUnknown Decemser 21,2078 at 6:41 AN 1. Which ofthe following methods are spoctc to StingBulders? Mark for Review (Points. ‘append cette ‘Abof tne above.) Income. Refer to Secon 3 Lesson * 12. Anonsnear recursive methed can al how many copies ote"? Mark for Review (Pods 2ormore(’) None 13. he base case condton can workwth @ constant or variable, Tru ofl? Mak or Review (Pais Tue) Incomec. Refer to Secon 3 Lesson. “4. Forward thinking helps when creating near ecutive methods. Tre o fale? Mark for Review (Pains we False) ‘corect 18.A Inoar recursive method diecy cals how many copies of self inthe recursive case? Mark for Rovow (Points 1° ormIncortec. Rees to Secon 3 Lesson 3. 4 Which ofthe folloing coral intalzes @ Matcher m for Pattern 9 and Sting tr? Mark for Review (Peis Matehor m= stmateharip) Matcher m= pmatcheris atone m= new Matcher str atone m= naw Mater Income, Refer to Section 3 Lesson 2. Whats the earect explanation of when his code wil tum tue? ‘tur smatonest'*0-]6)) Mark for Review (Pains ‘ay time that st contains two dot, ‘Any ime that str contains a sequence of 6 igs. (*) ‘Anytime tha st has botwoen zor an rine charactors folowed by a6, ‘Anytime sv contains 96 Aways. Income. Refer to Section 5 Lesson 2. 23. Your tacher asks you to wite a segment of code that rtums tro if Stings contains ze0 or ‘one characteris) and false cthorwise, Which of he flowing code segments competes ths atk? Mark or Review Pois (Choose sean answers) ‘elim stcotaina( A setenge0 {retum sue return fale: 0 selengty == 1) return smatchost o ‘elu states i-2"), Income, Refer to Secon 3 Lesson 4. na ragularexprssion, (x) and fk) ropresnt the same thing that th preceding charactor may ‘ceur x oF more tines to cate match “True orale? Mark fr Review (PainsFalse ¢) ‘5. Conder designing @ program that organizes your corals alphabetcaly by last name, then by ‘st name, Oday all of your contacts fst an last names are exaly ve leer long. inch ft folowing sopments of code establishes a Pattern namePattern with a group forthe {rt mare ar a grup forthe lastname conscering hat he sting contactsNare fs always the ‘format astName,frsiname? Mark fer Review (Peis Pattern namePatem = Pater comple) ((5)": C1 Pattern namoPator = Pato complet ast Pater namoPatom = new Patarnasts. ts) Pattern namePatter = new Pater Mane of te above, Income, Refer to Secon 3 Lesson 2, Reply ‘Unknown Decemer 21,2078 at 6:42AM 6. The falloning code coneilyintalzes a pattern withthe rogularaxprossion TO-8}2}T0-}210- ray. atin cate?» Paster compile (-8K240-82)(0-9]2") “Tuo or ata? Mark fr Review (Pains Fale Incomec. Refer to Secon 3 Lesson 7. Matener has find mathod that checks the specie patom exis 2 a sub-ting ofthe sing being matches “Tru or alee? Mark for Review (Pais Tuo) Fale Incomtact,Roer to Sacton 3 Lesson 2, 15. A notear recursive method is less expensive than near recursive method. Tue o flee? Mark for Review (PainsFalse ¢) 2. Which case nanate he last recursive ea? Mark fr Revow (Pots “The primary case ‘The base case) ‘The convergence case ‘The secondary case Income, Refer to Section 3 Lesson 3. 10. Anoringar cursive metod is ess expensive than 2 near recursive method. Tue or fa Mar for Raview (Poies False ¢) Incomtoc.Reer to Secon 3 Lesson 3. 1. Atnear recursive method dectly calls how many copes of Rf inthe recursive case? Mark for Review (Pains 2ormore Income. Reer to Section 3 Lesson 3. 12. ich of he flowing rete about the metrod split? Mark for Review (Pais {Choose al cont answors) Ihean be used wits sting s 2 parameter. (+ es cefault, wit no spectid parameter, i parsing by spaces. Ihean be used wit 9 gular expresion asa prameter () Ierotums an ary of sings.*)Incoroe Refer to Secon 3 Lesson * opty Unknown December 21,2018 at 6:44AM 13. Using the FOR loop method of Incementing Dough & Sting is benefcal you dese to: {Choose al tet apply) Mark for Review (Pains (Choose acon answers) Read he Sting backwards (om lst elemento fest lament). Search fora specie character or Sng inside of the Sting.) ‘You dont ute a FOR lop wih Stings Parse be Sting.) Inconoc, Refer lo Section 3 Lesson “A. ich ofthe fotoning corectyintatzes a StingBuller? Mark for Review (Pains StingBuibr st This is my Sting Buleor; _Sringataier 2b = Singular 600) ‘Stinger now Singur) None of te above, Income. Refer to Secon 3 Lesson 15. nich of he fotowing are ve about parsing a Sting? Mark for Revow (Pods {Choose a conct answors) Is not possible to parse a sting using regular expressions. Ihe a way of dividing a string no set of sub-stings. (7) Ihe posse to use afrloop to parse sing.) Ihe pose to use the Sting spt) method lo pare a sting.) Income. Refer to Sechon 3 Lessons 1. Which ofthe folowing erect defines a StingBuller? Mark for Review Pois ‘Alas that represents a stingtke object.) “Thor is no such thing 36a StringBuilder in Java-Ameod that adds characters toasting Inconoct, Refer lo Section 5 Lesson * 2, Using the FOR loop method of incrementing trough @ Sting is beneficial you deste to: {Choose al thal app) Mark for Review (Points (Choose al cont answers) ‘Searen or a spelfe character or Stag neds ofthe Sting.) Parse te Sting.) ‘Read he Sting backwards (am lst elemento fest element.) ‘Yu dont use a FOR lop with Stings Incorac Rafer to Secon 3 Lesson * ‘3. What clas isthe spit) method a mombor oF Mark for Review (Poin Sting () aerny ‘Singer ‘corect 4. Sols a mathod for Stings hat parsos a sting by pected character, of Wf unspeced, by spaces, ara retums the parsed elements in an aay of Seng “ru or alee? Mark for Review (nPoins we Fol (1 ‘corset 5. Your teacher asks yout wite a segment of code that rtums tue if Stings contains ze0 or ‘one character(s) and false cherwise, Which ofthe flowing code segments completes ts atk? Mark for Review (nPoins (Choose a eanect answors) ‘etum sxmathes(Ia-2"): A slong 0 selena
You might also like
Test: JF Java Fundamentals Final Exam
PDF
No ratings yet
Test: JF Java Fundamentals Final Exam
20 pages
Java Interview Notes
PDF
No ratings yet
Java Interview Notes
56 pages
JP Midterm Exam 2
PDF
100% (1)
JP Midterm Exam 2
7 pages
Prelim Lab Quiz 1
PDF
No ratings yet
Prelim Lab Quiz 1
7 pages
Section 1-5 Dan Midterm PDF
PDF
No ratings yet
Section 1-5 Dan Midterm PDF
72 pages
Java Programming
PDF
No ratings yet
Java Programming
331 pages
JAVA Placement Interview Questions
PDF
No ratings yet
JAVA Placement Interview Questions
66 pages
Important Interview Quitions
PDF
No ratings yet
Important Interview Quitions
34 pages
Java MCQS
PDF
100% (1)
Java MCQS
20 pages
What Is Java
PDF
No ratings yet
What Is Java
77 pages
Java Interview Questions
PDF
No ratings yet
Java Interview Questions
90 pages
Java Interview Questions For Freshers
PDF
No ratings yet
Java Interview Questions For Freshers
219 pages
For Basic Java Interview Questions 1723574250
PDF
No ratings yet
For Basic Java Interview Questions 1723574250
189 pages
JP Midterm Exam 1
PDF
0% (1)
JP Midterm Exam 1
7 pages
Java Programming Final Exam
PDF
No ratings yet
Java Programming Final Exam
5 pages
Final Exam
PDF
100% (1)
Final Exam
89 pages
Core Java Assignment 1: Name: Vansh Dilip Nagda Roll No: 381 Class: Syit
PDF
No ratings yet
Core Java Assignment 1: Name: Vansh Dilip Nagda Roll No: 381 Class: Syit
6 pages
UNIT I JAVA
PDF
No ratings yet
UNIT I JAVA
8 pages
Final
PDF
No ratings yet
Final
15 pages
JAVA (What is what)
PDF
No ratings yet
JAVA (What is what)
26 pages
320245-VIMP Java Questions
PDF
No ratings yet
320245-VIMP Java Questions
92 pages
Java Viva
PDF
No ratings yet
Java Viva
21 pages
Java Career Ride
PDF
No ratings yet
Java Career Ride
14 pages
Advanced Java Interview Questions and Answers
PDF
100% (1)
Advanced Java Interview Questions and Answers
21 pages
Java Interview Question
PDF
No ratings yet
Java Interview Question
4 pages
Java MCQ
PDF
No ratings yet
Java MCQ
25 pages
Java by Nageswara Rao
PDF
100% (1)
Java by Nageswara Rao
23 pages
Java by Nageswara Rao
PDF
No ratings yet
Java by Nageswara Rao
23 pages
Finalni Oracle
PDF
No ratings yet
Finalni Oracle
16 pages
Java MCQ
PDF
No ratings yet
Java MCQ
56 pages
Java Fundamentals Final Exam
PDF
88% (8)
Java Fundamentals Final Exam
83 pages
Java Assignment-1
PDF
No ratings yet
Java Assignment-1
27 pages
Java25-Unit1and2-Shortnotes
PDF
No ratings yet
Java25-Unit1and2-Shortnotes
26 pages
Interview Questions C and Java
PDF
No ratings yet
Interview Questions C and Java
39 pages
JAVA_VIVA_QA
PDF
No ratings yet
JAVA_VIVA_QA
8 pages
Prelim Lec Exam
PDF
No ratings yet
Prelim Lec Exam
18 pages
Soal Final Exam
PDF
100% (1)
Soal Final Exam
15 pages
4 - Week Java Notes 20cs43p
PDF
No ratings yet
4 - Week Java Notes 20cs43p
7 pages
20 Merged
PDF
No ratings yet
20 Merged
14 pages
Frequently Asked Interview Questions: Java Basics
PDF
No ratings yet
Frequently Asked Interview Questions: Java Basics
6 pages
Department of Computer Science: COMSATS University Islamabad, Abbottabad Campus
PDF
100% (1)
Department of Computer Science: COMSATS University Islamabad, Abbottabad Campus
6 pages
Computer Science tuition test paper 2024-2025
PDF
No ratings yet
Computer Science tuition test paper 2024-2025
3 pages
Solution Exam Questions Set 2 CSC2106 Object-Oriented Design & Programming
PDF
No ratings yet
Solution Exam Questions Set 2 CSC2106 Object-Oriented Design & Programming
12 pages
50 Java MCQ With Answers
PDF
No ratings yet
50 Java MCQ With Answers
18 pages
GC Quiz
PDF
No ratings yet
GC Quiz
15 pages
Compiled Interview Questions Advanced Java Developer Shuhrath Jamil
PDF
No ratings yet
Compiled Interview Questions Advanced Java Developer Shuhrath Jamil
4 pages
Java Notes Module2
PDF
No ratings yet
Java Notes Module2
6 pages
java ôn tập
PDF
No ratings yet
java ôn tập
92 pages
25 JAVA Specific Questions For Interviews-1
PDF
No ratings yet
25 JAVA Specific Questions For Interviews-1
7 pages
Java MCQ Solution
PDF
75% (4)
Java MCQ Solution
23 pages
Java Interview Questions
PDF
No ratings yet
Java Interview Questions
42 pages
1Q: What Is Java API?
PDF
No ratings yet
1Q: What Is Java API?
2 pages
OOP Final Model Paper 1st Sem
PDF
No ratings yet
OOP Final Model Paper 1st Sem
14 pages
Final Exam 2
PDF
0% (1)
Final Exam 2
23 pages