Constructors, Classes, and Inheritance
Constructors, Classes, and Inheritance
Questions
The protected access specifier works as ________ for outside world, but works as ________ for derived classes in Java.
- private and public
- public and private
- private and private
- public and public
If the first statement of a constructor has the form ________, then the constructor calls another constructor of the same class.
- static
- this(parameter list)
- this
- static(parameter list)
The protected access specifier is very useful in ___________ inheritance.
- simple
- multiple
- multilevel
- hierarchical
Which of the following classes is not a wrapper class?
- Float
- Integer
- Double
- String
- Byte
Final modifier can be applied to
- classes only
- methods only
- data members only
- classes, methods and data members
- interfaces only
All the data members in an interface are
- integers
- final
- protected
- private
- string
Select a valid answer with respect to the following piece of code.
class A
{
int value1;
}
class B extends A
{
int value2;
}
- Class A extends class B.
- Class B is superclass of class A.
- Class A inherits from class B.
- Class B is subclass of class A.
- Class A is subclass of class B.
If there are more than one constructors in a class, then it is termed as ____________.
- multi-constructor
- default Constructor
- constructor overloading
- constructor overriding
What is the minimum number of parameters in a constructor of Java?
- 0
- 1
- 2
- 3
Which type of inheritance is represented by the following code?
class A
{
}
class B extends A
{
}
- Simple inheritance
- Multilevel inheritance
- Multiple inheritance
- Hierarchical inheritance
Which type of inheritance is represented by the following code?
class A
{
}
class B extends A
{
}
class C extends B
{
}
- Simple inheritance
- Multilevel inheritance
- Multiple inheritance
- Hierarchical inheritance
Multiple inheritance can be implemented in Java using __________.
- classes
- interfaces
- structures
- static methods
A __________ class cannot be extended.
- public
- private
- abstract
- final
Which of the following is the implementation of the class structure given below?
-
||
|---|
| class A
{
}
class B
{
}
class C implements A,B
{
}| -
||
|---|
| class A
{
}
class B
{
}
class C implement A,B
{
}| -
||
|---|
| class A
{
}
class B
{
}
class C extends A,B
{
}| -
||
|---|
| class A
{
}
class B
{
}
class C extend A,B
{
}|

