// Java Quiz
5 questions · Test your fundamentals
Which keyword is used to print output to the console in Java?
System is a class, out is a PrintStream field, and println prints the text followed by a newline.
What is the output of the following code?
int. The decimal part is truncated, so 5 / 2 = 2, not 2.5. To get 2.5, cast one operand to double: (double) x / y.
In Java, which access modifier makes a class member accessible only within the same class?
public = everywhere; protected = same package + subclasses; default (no modifier) = same package only.
How many times will the following loop print "Hello"?
i = 0 and runs while i < 5, so it executes for i = 0, 1, 2, 3, 4 — exactly 5 iterations.
Which method is used to find the number of characters in a Java String?
"Java".length() returns 4. Note: arrays use .length (property), but Strings use .length() (method).
You answered 0 out of 5 correctly.