What is the fundamental difference between Java and JavaScript?
Java is a statically-typed language, while JavaScript is dynamically-typed.
Java is primarily used for client-side web development, while JavaScript is used for server-side applications.
Java is a scripting language, while JavaScript is a compiled language.
They are essentially the same; the names are interchangeable.
What is the purpose of the 'switch' statement in Java?
To declare a variable
To check a condition and execute different code blocks based on the result
To define a method
To execute a block of code repeatedly
Which access modifier allows a subclass in a different package to access a member of its superclass?
public
private
protected
default
Which keyword is used to explicitly throw an exception in Java?
try
finally
catch
throw
What is the difference between a class and an object in Java?
There is no difference; they are interchangeable terms.
A class is a blueprint, while an object is a physical entity.
A class is a variable type, while an object is a function.
A class defines properties and behavior, while an object is an instance of a class.
Which keyword is used to define a method in Java?
void
function
define
method
Which of the following is NOT a valid access modifier in Java?
static
What will the following Java code snippet print to the console?
for (int i = 1; i <= 3; i++) { System.out.print(i + " "); }
1 2 3
3 2 1
123
The code will result in a compilation error.
Which keyword is used to define a block of code that might throw an exception?
What will be the value of 'x' after executing the following Java code snippet?
int x = 5; x = x++ + ++x;
11
12
10