Java Constructor and Methods

Programming Language > Java Programming Language

Evaluate your understanding of Java constructors and methods with these multiple choice questions. Learn about the different types of constructors and methods in Java and how to use them in your programs. Take the quiz now! ➲ Java Constructor and Methods - Quiz


  • A Won't compile because of line (1), constructor can't be private
  • B 10 50
  • C 50
  • D Won't compile because of line (5), constructor can't be static
  • A 3.0
  • B 3
  • C 4
  • D 4.0
  • A (int)Math.random()
  • B (int)Math.random() + 1
  • C (int)(Math.random() + 0.5)
  • D (int)(Math.random() + 0.2)
  • A void
  • B int
  • C double
  • D None of the above
  • A At line 1, constructor Tester must be marked public like its class
  • B At line 2, constructor call
  • C At line 3, compilation error, ambiguity problem, compiler can't determine whether a constructor
  • D At line 4
  • A reference variables
  • B objects
  • C instance variables
  • D None of these
  • A public
  • B private
  • C static
  • D protected
  • A Won't compile because of line (1); constructor can't be private
  • B Won't compile because of line (5); constructor can't be final
  • C 50
  • D 10 50
  • A An object, variable or method goes out of scope.
  • B An object or variable goes out of scope.
  • C A variable goes out of scope.
  • D Before garbage collection.
  • A It can be accessed easily by the class loader.
  • B It can be accessed by every method or variable without any hindrance.
  • C It can be executed without creating any instance of the class.
  • D None of the above
  • A public Test(void)
  • B Test( )
  • C Test(void)
  • D public Test( )
  • A Compile fail due to error on line no 2
  • B Compile fail due to error on line no 9
  • C Compile fail due to error on line no 8
  • D 15
  • A MyClass(){}
  • B 1 and 3
  • C public MyClass(){}
  • D public MyClass(void){}
  • A One
  • B Compilation fails due to an error on line 1
  • C Compilation fails due to an error on line 2
  • D Compilation succeed but no output.
  • A void atnyla() {} throws IOException
  • B void atnyla() throws IOException{}
  • C void atnyla() throw IOException{}
  • D void atnyla(void) throws IOException{}