Java Interviews MCQs - Quiz

  • A Yes, both overloading and overriding are possible for static methods in Java.
  • B No, static methods cannot be overloaded or overridden in Java.
  • C Overloading is possible but overriding is not allowed for static methods in Java.
  • D Overriding is possible but overloading is not allowed for static methods in Java.
  • A The program will fail to compile.
  • B The program will compile and run, but the main method will not be executed.
  • C The program will compile and run, but it will generate a runtime error.
  • D The program will compile and run normally.
  • A Local variables have scope within the block where they are declared.
  • B Instance variables have scope within the class where they are defined.
  • C Class variables (static variables) have scope within the class and its subclasses.
  • 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 Object cloning is the process of creating an exact copy of an object.
  • B Object cloning is the process of creating a new object using a copy constructor.
  • C Object cloning is the process of creating a new object with the same reference as the original object.
  • D Object cloning is not supported in Java.
  • A It would lead to ambiguity and confusion during method resolution.
  • B It violates the principles of object-oriented programming.
  • C Java does not support dynamic dispatch based on return types.
  • D All of the above.
  • 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 Multiple inheritance and operator overloading
  • B Garbage collection and exception handling
  • C Polymorphism and encapsulation
  • D Dynamic memory allocation and function templates