Java Interviews MCQs - Quiz

  • A It allows the method to be called without creating an instance of the class.
  • B It ensures that the main method is executed first when the program starts.
  • C It enables the main method to access static variables and methods directly.
  • D All of the above.
  • A It refers to the current instance of the class.
  • B It refers to the superclass of the current class.
  • C It refers to the static context of the class.
  • D It refers to the object being passed as a parameter to a method.
  • A An abstract class is a class that cannot be instantiated and can only be inherited.
  • B An abstract class is a class that can be instantiated but cannot be inherited.
  • C An abstract class is a class that can only contain abstract methods.
  • D An abstract class is a class that can only contain static methods.
  • A Yes, the main() method can be overloaded in Java.
  • B No, the main() method cannot be overloaded in Java.
  • C Overloading the main() method is possible, but it is considered bad practice.
  • D Overloading the main() method is possible, but it will cause a runtime error.
  • A In Java, multiple inheritance is supported, while in C++ it is not.
  • B In C++, multiple inheritance is supported, while in Java it is not.
  • C In Java, all classes inherit from a common superclass, while in C++ they do not.
  • D In C++, classes can have multiple levels of inheritance, while in Java they cannot.
  • A A blank final variable is a variable that is not assigned any initial value and remains constant throughout the program.
  • B A blank final variable is a variable that is declared with the "final" keyword but can be assigned a value later in the program.
  • C A blank final variable is a variable that is declared without any data type specified.
  • D A blank final variable is a variable that is not declared with any modifiers or keywords.
  • A A static variable is a variable that is accessible only within the static methods of a class.
  • B A static variable is a variable that is shared among all instances of a class and is not specific to any particular instance.
  • C A static variable is a variable that is declared with the "static" keyword and cannot be changed once assigned a value.
  • D A static variable is a variable that is declared inside a static block in a class.
  • A HashMap allows null values and is not synchronized, while HashTable does not allow null values and is synchronized.
  • B HashTable allows null values and is not synchronized, while HashMap does not allow null values and is synchronized.
  • C Both HashMap and HashTable allow null values, but HashMap is not synchronized while HashTable is synchronized.
  • D Both HashMap and HashTable do not allow null values, but HashMap is synchronized while HashTable is not synchronized.
  • A Java objects are stored in a stack memory.
  • B Java objects are stored in a heap memory.
  • C Java objects are stored in a separate memory space called the "object memory."
  • D Java objects are stored in a cache memory.