Which of the following is NOT a valid access modifier in Java?
private
public
protected
static
In Java, what is an instance of a class?
A variable that stores data
A blueprint or template for creating objects
A method that performs a specific action
A concrete, realized version of a class
What is the role of methods in a Java class?
To perform actions or operations on an object's data
To control the visibility of class members
To define the blueprint for creating objects
To store data associated with an object
What is essential to prevent infinite recursion in a Java method?
A loop within the recursive method
A return statement in all code paths
Using a different method name for each recursive call
A conditional statement that terminates the recursion
What is the primary difference between an array and an ArrayList in Java?
Arrays are part of the Java Collections Framework, while ArrayLists are not.
Arrays are fixed in size, while ArrayLists are dynamically sized.
Arrays can store objects of different classes, while ArrayLists can only store objects of the same class.
Arrays can store primitive data types, while ArrayLists cannot.
What will the following Java code snippet print to the console?
for (int i = 1; i <= 3; i++) { System.out.print(i + " "); }
3 2 1
1 2 3
123
The code will result in a compilation error.
What does it mean for a method to have a 'void' return type?
The method is not yet implemented.
The method returns an empty string.
The method throws an exception.
The method doesn't return any value.
What is the result of the expression '10 % 3' in Java?
0
3
3.33
1
Which Java keyword is used to make a decision between two blocks of code based on a condition?
for
if
switch
while
What is the fundamental difference between Java and JavaScript?
They are essentially the same; the names are interchangeable.
Java is a scripting language, while JavaScript is a compiled language.
Java is primarily used for client-side web development, while JavaScript is used for server-side applications.
Java is a statically-typed language, while JavaScript is dynamically-typed.