TOTAL QS = 22Time [ 00 : 00 : 00 ]
00:00:00

Java Constructor Overloading Basics Online Test 1

Instructions

Total Questions: 22

Total Minutes: 22

This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on basics of Java Constructor Overloading. This test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics.

Go through Java Theory Notes on Constructor Overloading before attempting this test.

All the Best

Challenge SCORE

0 / 22

Take This Exam
1) A Java constructor is like a method without ___.
2) The name of a constructor and the name of a class are ___.
3) The placement of a constructor inside a class should be ___.
4) The purpose of a Java constructor is ___.
5) Memory is allocated to an object once the execution of ___ is over in Java language.
6) What is the output of the below Java program?
public class TestingConstructor
{
  void TestingConstructor()
  {
    System.out.println("Amsterdam");	
  }

  TestingConstructor()
  {
    System.out.println("Antarctica");	
  }
	
  public static void main(String[] args)
  {
    TestingConstructor tc = new TestingConstructor();
  }
}
7) In Java, a constructor with no parameters or no arguments is called ___ constructor.
8) In Java, a constructor with one or more arguments or parameters is called a ___ constructor.
9) The compiler adds a default no-argument constructor to a class if it ___.
10) Overloading of constructors in Java means adding more than ___ constructors with the different argument list.
11) What is the output of the below Java program with constructors?
public class Constructor2
{
  int count=10;
  Constructor2(int count)
  {
    System.out.println("Count=" + count);
  }

  public static void main(String[] args)
  {
    Constructor2 con = new Constructor2();
  }
}
12) A constructor can call another overloaded constructor using the ___ keyword in Java.
13) What is the output of the below Java program with overloaded constructors?
public class Constructor3
{
  int birds=10;
  Constructor3()
  {
    this(20);
  }
  Constructor3(int birds)
  {
    System.out.println("Birds=" + birds);
  }

  public static void main(String[] args)
  {
    Constructor3 con = new Constructor3();
  }
}
14) In Java, you can pass __ variables from one constructor to another overloaded constructor.
15) Choose the correct way of calling the second constructor from the first constructor in the below code options.
16) What is the output of the below Java program with many constructors?
public class Constructor7
{
  Constructor7(int a)
  {
    System.out.println("Book=" + a);
  }
  Constructor7(float a)
  {
    System.out.println("Pen="+ a );
  }
  public static void main(String[] args)
  {
    Constructor7 con = new Constructor7(50.5f);
  }
}
17) What is the output of the below Java program with many constructors?
public class Constructor8
{
  Constructor8(boolean a)
  {
    System.out.println("MODEM="+ a );
  }
  Constructor8(float a)
  {
    System.out.println("ROUTER=" + a);
  }
  public static void main(String[] args)
  {
    Constructor8 con1 = new Constructor8(50);
    Constructor8 con2 = new Constructor8(false);
  }
}
18) What is the output of the below Java program with overloaded constructors?
public class Jiraffe
{
  Jiraffe(int sugarcanes)
  {
    System.out.println("Eats "+ sugarcanes + " Sugarcanes");
  }
  Jiraffe(int age, int...sugarcanes)
  {
    System.out.println("Eats "+ sugarcanes[0] + " Sugarcanes");
  }
  public static void main(String[] args)
  {
    Jiraffe jiff2 = new Jiraffe(40);
    Jiraffe jiff = new Jiraffe(5,10);
  }
}
19) Choosing a suitable overloaded constructor happens at ___ time in Java.
20) Java constructor overloading follows ___ principle in Object-Oriented programming.
21) Java allows calling or invoking a method from a constructor. State TRUE or FALSE.
22) What is the output of the below Java program?
public class Constructor9
{
  Constructor9()
  {
    show();	
  }
  void show()
  {
    System.out.println("JAM JAM");
  }
  public static void main(String[] args)
  {
    Constructor9 con = new Constructor9();
  }
}

Open Certification Helper Popup Reset Popup