Quiz
OCAJP8 Chapter 1
Dieses Quiz hat ein Zeitlimit und öffnet sich deshalb im gewohnten Player.
Fragen in diesem Quiz (50)
1Given the code fragment

- A200.0 : 100.0
- B400.0 : 200.0
- C400.0 : 100.0
- DCompilation fails
2given Fragment

- A10 Hello World!
- BHello Universe!
- CHello World!
- DCompilation fails.
3Given the code fragment:
What is the result?
- ASum is 600
- BCompilation fails at line n1.
- CCompilation fails at line n2.
- DA ClassCastException is thrown at line n1.
- EA ClassCastException is thrown at line n2.
4Given the code fragment:

- AAn exception is thrown at runtime.
- B2
- C5
- D0
5Given the code fragment:
- AMatch 1
- BMatch 2
- CNo Match
- DA NullPointerException is thrown at runtime.
6Given :
- AA B C D
- BA C D
- CA B C C
- DA B D
- EA B D C
7Which code fragment should you use at line n1 to instantiate the dvd object successfully?
- AOption A
- BOption A
- COption C
- DOption D
- AOption A
8Which option can replace xxx to enable the code to print 135?
- Aint e = 0; e < = 4; e++
- Bint e = 0; e < 5; e + = 2
- Cint e = 1; e < = 5; e + = 1
- Dint e = 1; e < 5; e+ =2
9Which statement best describes encapsulation?
- AEncapsulation ensures that classes can be designed so that only certain fields and methods of an
object are accessible from other objects. - BEncapsulation ensures that classes can be designed so that their methods are inheritable.
- CEncapsulation ensures that classes can be designed with some fields and methods declared as
abstract. - DEncapsulation ensures that classes can be designed so that if a method has an argument MyType
x, any subclass of MyType can be passed to that method.
- AEncapsulation ensures that classes can be designed so that only certain fields and methods of an
10Which code fragment, when inserted at line 2, enables the code to compile?
- AOption A
- BOption B
- COption C
- DOption D
- EOption E
- AOption A
11Which code fragment prints red: blue: small: medium?
- AOption A
- BOption B
- COption C
- DOption D
- AOption A
12What is the result?
- AReading Card
Checking Card - BCompilation fails only at line n1.
- CCompilation fails only at line n2.
- DCompilation fails only at line n3.
- ECompilation fails at both line n2 and line n3.
- AReading Card
13Which modification enables the code to print 54321?
- AReplace line 6 with System, out. print (--x) ;
- BAt line 7, insert x --;
- CReplace line 6 with --x; and, at line 7, insert system, out. print (x);
- DReplace line 12 With return (x > 0) ? false: true;
14Which modification enables the code fragment to print TrueDone?
- AReplace line 5 With String opt = "true";
Replace line 7 with case "true": - BReplace line 5 with boolean opt = l;
Replace line 7 with case 1= - CAt line 9, remove the break statement.
- DRemove the default section.
- AReplace line 5 With String opt = "true";
15What is the result?
- A5 4 3 2 1 0
- B5 4 3 2 1
- C4 2 1
- D5
- ENothing is printed
16What is the result?
- A100
- B101
- C102
- D103
- ECompilation fails
17What is the result?
- A97 98
99 100 null null null - B97 98
99 100 101 102 103 - CCompilation rails.
- DA NullPointerException is thrown at runtime.
- EAn ArraylndexOutOfBoundsException is thrown at runtime.
- A97 98
18Which two modifications, when made independently, enable the code to print joe:true: 100.0?
- AOption A
- BOption B
- COption D
- DOption E
- AOption A
19What is the result?
- A[Robb, Rick, Bran]
- B[Robb, Rick]
- C[Robb, Bran, Rick, Bran]
- DAn exception is thrown at runtime.
20What is the result?
- AC B A
- BC
- CA B C
- DCompilation fails at line n1 and line n2
21What is the result?
- A3 4 5 6
- B3 4 3 6
- C5 4 5 6
- D3 6 4 6
22Which code fragment, when inserted at line 3, enables the code to print 10:20?
- Aint[] array n= new int[2];
- Bint[] array;
array = int[2]; - Cint array = new int[2];
- Dint array [2] ;
23What is the result?
- AA B C Work done
- BA B C D Work done
- CA Work done
- DCompilation fails
24Which set of commands prints Hello Duke in the console?
- AOption A
- BOption B
- COption C
- DOption D
- AOption A
25What is the result?
- AOption A
- BOption B
- COption C
- DOption D
- AOption A
26What is the result?
- A2 4
- B0 2 4 6
- C0 2 4
- DCompilation fails
27Assume that the system date is June 20, 2014. What is the result?
- AOption A
- BOption B
- COption C
- DOption D
- AOption A
28Which code fragment, when inserted at line 9, enables the code to print true?
- AString str2 = str1;
- BString str2 = new String (str1);
- CString str2 = sb1. toString ();
- DString str2 = "Duke";
29What is the result?
- A10 : 10
- B5 : 5
- C5 : 10
- DCompilation fails
30And given the commands:
javac Test.Java
Java Test Hello
What is the result?- ASuccess
- BFailure
- CCompilation fails.
- DAn exception is thrown at runtime
31What is the output?
- A4
4 - B3
5 - C4
7 - D4
5
- A4
32What are the values of each element in intArr after this code has executed?
- A15, 60, 45, 90, 75
- B15, 90, 45, 90, 75
- C15, 30, 75, 60, 90
- D15, 30, 90, 60, 90
33Which statement is true?
- AOnly the A.Java file compiles successfully
- BOnly the B.java file compiles successfully
- COnly the C.java file compiles successfully.
- DThe A.Java and B.java files compile successfully.
34What is the result?
- A400 200
- B200 200
- C400 400
- DCompilation fails.
35Given the following class declarations:
public abstract class Animal
public interface Hunter
public class Cat extends Animal implements Hunter
public class Tiger extends Cat
Which answer fails to compile?- AOption A
- BOption B
- COption C
- DOption D
- EOption E
36Which statement is true about Java byte code?
- AIt can run on any platform
- BIt can run on any platform only if it was compiled for that platform
- CIt can run on any platform that has the Java Runtime Environment
- DIt can run on any platform that has a Java compiler
37How many MarkList instances are created in memory at runtime?
- A2
- B1
- C3
- D4
38What is the result?
- AArea is 6.0
- BArea is 3.0
- CCompilation fails at line n1
- DCompilation fails at line n2.
39What is the result?
- ATrue false
- BTrue NULL
- CCompilation fails
- DA NullPointerException is thrown at runtime
40What is the result?
- AA
- BB
- CEither A or B
- DA B
- EA compile time error occurs at line n1
41What is the result?
- AmyStr: 9009, myNum: 9009
- BmyStr: 7007, myNum: 7007
- CmyStr: 7007, myNum: 9009
- DCompilation fails
42What is the result?
- A1:2:3:4:5:
- B1:2:3:
- CCompilation fails.
- DAn ArrayoutofBoundsException is thrown at runtime.
43What is the result?
- Atrue:true
- Btrue:false
- Cfalse:true
- Dfalse:false
44Which one of the following code examples uses valid Java syntax?
- AOption A
- BOption B
- COption C
- DOption D
45What is the result?
- A1324
- B2413
- C3142
- D4231
46What is the result?
- AAn exception is thrown at runtime.
- BInitialized
Started
Initialized - CInitialized
Started - DCompilation fails.
47What is the result?
- AAnswer = 0
- BInvalid calculation
- CCompilation fails only at line n1.
- DCompilation fails only at line n1 and line2.
48What is the result?
- A100 0 : 100 200:
- B100 0 : 100 0 :
- C100 200 : 100 200 :
- D100 200 : 100 0 :
49What is the result?
- Ae, e
i, o - Ba, e
i, o - Ca,e
o, o - De, e
o, o
- Ae, e
50What is the result if the integer aVar is 9?
- ACompilation fails.
- B10 Hello Universe!
- C10 Hello World!
- D9 Hello World!
Informationen
- Beschreibung
- Quiz am OCAJP8 Chapter 1, erstellt von Muhammad Khoiruddin Harahap am 21/11/2017.
- Sprache
- English
- Aufrufe
- 26
- Bewertung
- Noch keine Bewertungen Bewerte dieses Quiz