What will be the value of 'x' after executing the following Java code snippet?
int x = 5; x = x++ + ++x;
The code will result in a compilation error.
10
12
11
What is the parent class of all exception classes in Java?
Error
Exception
RuntimeException
Throwable
What is the difference between a class and an object in Java?
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.
There is no difference; they are interchangeable terms.
A class is a blueprint, while an object is a physical entity.
What is the correct syntax to print 'Hello World!' to the console in Java?
System.out.println('Hello World!');
print('Hello World!');
console.log('Hello World!');
echo 'Hello World!';
What will happen if you try to access an element at an invalid index in an ArrayList?
It will throw an ArrayIndexOutOfBoundsException.
It will return null.
The program will crash.
It will throw a NullPointerException.
What are fields in a Java class?
Keywords reserved by the Java language
Methods that belong to the class
Variables that hold the state of an object
Constructors used to create objects
What is the default access modifier for a class member in Java if none is specified?
default (package-private)
public
private
protected
Which of these is a valid way to call a method named 'calculateArea' in Java?
calculateArea()
calculateArea;
call calculateArea()
Area.calculate()
What is the core principle behind Object-Oriented Programming (OOP) in Java?
Improved memory management
Faster execution speed
Data security
Code reusability
Which method is used to add an element to the end of an ArrayList?
append()
insert()
add()
push()