Quiz
OCP Chapter 2
Erstelle ein kostenloses Konto, um dieses Quiz zu beenden
Speichere deinen Fortschritt und sieh dir dein Endergebnis an.
oder mit deiner E-Mail registrieren
Schon ein Konto? Anmelden
Fragen in diesem Quiz (10)
1Which of the following are valid Java Identifiers?
- A_
- B_helloWorld$
- Ctrue
- Djava.lang
- EPublic
- F1980_s
- G_Q2_
2What lines are printed by the following program?
- ALine 8 generates a compiler error
- BLine 9 generates a compiler error
- CEmpty =
- DEmpty = false
- EBrand =
- FBrand = null
- GCode = 0.0
- HCode = 0f
3Which of the following code snippets about var compile without issue when used in a method?
- Avar spring = null;
- Bvar fall = "leaves";
- Cvar evening = 2; evening = null;
- Dvar night - new Object();
- Evar day = 1/0;
- Fvar winter = 12, cold;
- Gvar fall = 2, autumn = 2;
- Hvar morning = "", morning = null;
4Which of the following statements about the code snippet are true?
4. short numPets 5L;
5. int numGrains = 2.0;
6. String name = "Scruffy";
7. int d = numPets.length();
8. int e = numGrains.length;
9. int f = name.length();- ALine 4 generates a compiler error
- BLine 5 generates a compiler error
- CLine 6 generates a compiler error
- DLine 7 generates a compiler error
- ELine 8 generates a compiler error
- FLine 9 generates a compiler error
5Which statements about the following class are true:
- ALine 3 generates a compiler error
- BLine 6 generates a compiler error
- CLine 7 generates a compiler error
- DLine 10 generates a compiler error
- EThe program prints 3 on line 10
- FThe program prints 4 on line 10
- GThe program prints 50.0 on line 11
- HThe program prints 49.0 on line 11
6Which are the following are correct
- AAn instance var of type float defaults to 0
- BAn instance var of type char defaults to null
- CAn instance var of type double defaults to 0.0
- DAn instance var of type int defaults to null
- EAn instance var of type String defaults to null
- FAn instance var of type String defaults to the empty string "".
- GNone of the above
7Which of the following are correct
- AA local variable of type boolean defaults to null
- BA local variable of type float defaults to 0.0f
- CA local variable of type double defaults to 0
- DA local variable of type Object defaults to null
- EA local variable of type boolean defaults to false
- FA local variable of type float defaults to 0.0
- GNone of the above
8Which of the following class statements are true
- AA class variable of type boolean defaults to 0
- BA class variable of type boolean defaults to false
- CA class variable of type boolean defaults to null
- DA class variable of type long defaults to null
- EA class variable of type long defaults to 0L
- FA class variable of type long defaults to 0
- GNone of the above
9Which of the following statements about garbage collection are true?
- ACalling System.gc() is guaranteed to free up memory by destroying objects eligible for garbage collection
- BGarbage collection runs on a set schedule
- CGarbage collection allows the JVM to reclaim memory for other objects
- DGarbage collection runs when your program has used up half the available memory
- EAn object may be eligible for garbage collection but never removed from the heap
- FAn object is eligible for garbage collection once no references to it are accessible in the program
- GMarking a variable as final means its associated object will never be garbage collected
10Which statements about the following class are correct?
- AIt prints Q1=blue
- BIt prints Q2 = 1200
- CIt prints P1 = null
- DIt prints P2 = 1400
- ELine 4 does not compile
- FLine 12 does not compile
- GLine 13 does not compile
- HNone of the above
Informationen
- Beschreibung
- Quiz am OCP Chapter 2, erstellt von Jack Hughes am 10/03/2021.
- Autor
- Jack Hughes
- Sprache
- English
- Aufrufe
- 0
- Schlagwörter
- Bewertung
- Noch keine Bewertungen Bewerte dieses Quiz