Java Language Fundamentals Flashcards
7 cards from real 1Z0-811 practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Java Language Fundamentals flashcards as text
Which of the following is true about local variables in Java?
Answer: They must be explicitly initialized before use
Local variables have no default value in Java; the compiler raises an error if you use one before initializing it.
What is the output of the following? int[] arr = {5, 10, 15}; System.out.println(arr.length);
Answer: 3
The array has three elements (5, 10, 15), so arr.length returns 3.
Which of the following correctly describes a labeled break statement?
Answer: It breaks from a specified outer loop
A labeled break exits the loop (or block) associated with the specified label, not just the innermost one.
What does the following evaluate to? 10 == 10.0
Answer: true, after numeric promotion
Java promotes the int 10 to double 10.0 before comparison, so 10 == 10.0 evaluates to true.
Which of the following is true about the 'static' keyword on a variable?
Answer: It creates a class-level variable shared by all instances
A static variable belongs to the class rather than any instance; all objects share the same copy.
What is printed by this code? int i = 10; do { System.out.print(i + " "); i--; } while (i > 10);
Answer: 10
A do-while loop always executes the body at least once, so 10 is printed; then i becomes 9, failing the condition i>10.
Which of the following is a correct way to declare a constant in Java?
Answer: final int MAX = 100;
Java uses 'final' (optionally combined with 'static') to declare constants; 'const' is a reserved word but unused.