What is the result of the following code in Java? `System.out.println(5 / 0);`
A. Compilation Error
B. Infinity
C. It throws an ArithmeticException
D. 0
Select an option to see the answer and solution.
In Java, which data type is used to represent true or false values?
A. int
B. double
C. char
D. boolean
Select an option to see the answer and solution.
What does the `break` statement do when used in a `switch` statement in Java?
A. It exits the `switch` statement and continues with the next statement after it
B. It ends the program execution
C. It restarts the `switch` statement from the beginning
D. It skips the current case and continues with the next case
Select an option to see the answer and solution.
Which Java keyword is used to explicitly specify that a variable cannot be changed after it is assigned a value?
A. immutable
B. static
C. const
D. final
Select an option to see the answer and solution.
What is the purpose of the `String.format()` method in Java?
A. To define JavaBean properties
B. To execute SQL queries
C. To format strings based on a format string and arguments
D. To create JavaBeans
Select an option to see the answer and solution.
Which Java keyword is used to define a constant interface?
A. const
B. final
C. constant
D. None of These
Select an option to see the answer and solution.
What is the purpose of the `@SuppressWarnings` annotation in Java?
A. To create JavaBeans
B. To execute SQL queries
C. To suppress compiler warnings for specific code
D. To define JavaBean properties
Select an option to see the answer and solution.
In Java, which collection class does not allow duplicate elements and is typically implemented as a binary tree?
A. HashSet
B. ArrayList
C. LinkedList
D. TreeSet
Select an option to see the answer and solution.
What is the result of the following code in Java? `System.out.println(10 > 5 ? "true" : "false");`
A. true
B. false
C. Compilation Error
D. Runtime Error
Select an option to see the answer and solution.
In Java, which exception is thrown when an attempt is made to access an array element with an index that is negative or greater than or equal to the array size?
A. OutOfBoundsException
B. ArrayOutOfBoundsError
C. IndexOutOfBoundsException
D. ArrayIndexOutOfBoundsException
Select an option to see the answer and solution.
Which Java keyword is used to define a subclass that inherits from another class?
A. implements
B. inherits
C. extends
D. subclass
Select an option to see the answer and solution.
What does the `super` keyword refer to in Java?
A. It executes SQL queries
B. It refers to the superclass of the current class
C. It creates JavaBeans
D. None of These
Select an option to see the answer and solution.
In Java, what is the purpose of the `transient` keyword when applied to an instance variable?
A. To create JavaBeans
B. To execute SQL queries
C. It indicates that the variable should not be serialized
D. To define JavaBean properties
Select an option to see the answer and solution.
What is the output of the following code snippet in Java? `System.out.println(Math.pow(2, 3));`
A. 6
B. 2
C. Compilation Error
D. 8
Select an option to see the answer and solution.
Which Java operator is used to perform a bitwise XOR operation between two integers?
Select an option to see the answer and solution.
What is the purpose of the `instanceof` operator in Java?
A. To create JavaBeans
B. To execute SQL queries
C. To define JavaBean properties
D. To check if an object is an instance of a particular class or interface
Select an option to see the answer and solution.
In Java, which exception is thrown when an object is accessed before it has been initialized?
A. InitializationException
B. ObjectNotInitializedException
C. NullPointerException
D. NullReferenceException
Select an option to see the answer and solution.
Which Java class is used to represent an ordered collection of elements?
A. Map
B. List
C. Queue
D. None of These
Select an option to see the answer and solution.
What is the purpose of the `synchronized` keyword in Java?
A. To create JavaBeans
B. To execute SQL queries
C. To create a synchronized block of code for multithreading
D. To define JavaBean properties
Select an option to see the answer and solution.
In Java, what does the `this` keyword refer to?
A. It defines JavaBean properties
B. It executes SQL queries
C. It creates JavaBeans
D. It refers to the current instance of the class
Select an option to see the answer and solution.