Constructors, Classes, and Inheritance

Constructors, Classes, and Inheritance

14 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

The protected access specifier works as ________ for outside world, but works as ________ for derived classes in Java.

  1. private and public
  2. public and private
  3. private and private
  4. public and public
Question 2 Multiple Choice (Single Answer)

If the first statement of a constructor has the form ________, then the constructor calls another constructor of the same class.

  1. static
  2. this(parameter list)
  3. this
  4. static(parameter list)
Question 3 Multiple Choice (Single Answer)

The protected access specifier is very useful in ___________ inheritance.

  1. simple
  2. multiple
  3. multilevel
  4. hierarchical
Question 4 Multiple Choice (Single Answer)

Which of the following classes is not a wrapper class?

  1. Float
  2. Integer
  3. Double
  4. String
  5. Byte
Question 5 Multiple Choice (Single Answer)

Final modifier can be applied to

  1. classes only
  2. methods only
  3. data members only
  4. classes, methods and data members
  5. interfaces only
Question 6 Multiple Choice (Single Answer)

All the data members in an interface are

  1. integers
  2. final
  3. protected
  4. private
  5. string
Question 7 Multiple Choice (Single Answer)

Select a valid answer with respect to the following piece of code.
class A
{
int value1;
}
class B extends A
{
int value2;
}

  1. Class A extends class B.
  2. Class B is superclass of class A.
  3. Class A inherits from class B.
  4. Class B is subclass of class A.
  5. Class A is subclass of class B.
Question 8 Multiple Choice (Single Answer)

If there are more than one constructors in a class, then it is termed as ____________.

  1. multi-constructor
  2. default Constructor
  3. constructor overloading
  4. constructor overriding
Question 9 Multiple Choice (Single Answer)

What is the minimum number of parameters in a constructor of Java?

  1. 0
  2. 1
  3. 2
  4. 3
Question 10 Multiple Choice (Single Answer)

Which type of inheritance is represented by the following code?
class A
{
}
class B extends A
{
}

  1. Simple inheritance
  2. Multilevel inheritance
  3. Multiple inheritance
  4. Hierarchical inheritance
Question 11 Multiple Choice (Single Answer)

Which type of inheritance is represented by the following code?
class A
{
}
class B extends A
{
}
class C extends B
{
}

  1. Simple inheritance
  2. Multilevel inheritance
  3. Multiple inheritance
  4. Hierarchical inheritance
Question 12 Multiple Choice (Single Answer)

Multiple inheritance can be implemented in Java using __________.

  1. classes
  2. interfaces
  3. structures
  4. static methods
Question 13 Multiple Choice (Single Answer)

A __________ class cannot be extended.

  1. public
  2. private
  3. abstract
  4. final
Question 14 Multiple Choice (Single Answer)

Which of the following is the implementation of the class structure given below?


  1. ||
    |---|
    | class A
    {
    }
    class B
    {
    }
    class C implements A,B
    {
    }|

  2. ||
    |---|
    | class A
    {
    }
    class B
    {
    }
    class C implement A,B
    {
    }|

  3. ||
    |---|
    | class A
    {
    }
    class B
    {
    }
    class C extends A,B
    {
    }|

  4. ||
    |---|
    | class A
    {
    }
    class B
    {
    }
    class C extend A,B
    {
    }|