a) true b) false Answer: b Explanation: Static members are also inherited to subclasses.
View QuestionIf super class and subclass have same variable name, which keyword should be used to use super class?
a) super b) this c) upper d) classname Answer: a Explanation: ...
View QuestionIn order to restrict a variable of a class from inheriting to subclass, how variable should be declared?
a) Protected b) Private c) Public d) Static Answer: b Explanation: By declaring ...
View QuestionAll classes in Java are inherited from which class?
a) java.lang.class b) java.class.inherited c) java.class.object d) java.lang.Object Answer: d Explanation: All classes in ...
View QuestionUsing which of the following, multiple inheritance in Java can be implemented?
a) Interfaces b) Multithreading c) Protected methods d) Private methods Answer: a Explanation: Multiple ...
View QuestionWhat is not type of inheritance?
a) Single inheritance b) Double inheritance c) Hierarchical ...
View Question
What will be the output of the following Java program?
class A
{
public int i;
public int j;
A()
{
i = 1;
j = 2;
}
}
class B extends A
{
int a;
B()
{
super();
}
}
class super_use
{
public static void main(String args[])
{
B obj = new B();
System.out.println(obj.i + ” ” + obj.j)
}
}
What will be the output of the following Java program? class A ...
View Question
What will be the output of the following Java program?
class A
{
int i;
}
class B extends A
{
int j;
void display()
{
super.i = j + 1;
System.out.println(j + ” ” + i);
}
}
class inheritance
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
What will be the output of the following Java program? class A ...
View Question
What will be the output of the following Java program?
class A {
int i;
void display() {
System.out.println(i);
} }
class B extends A {
int j;
void display()
{
System.out.println(j);
}
}
class inheritance_demo {
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
} }
What will be the output of the following Java program? class A ...
View QuestionWhich of these is correct way of inheriting class A by class B?
a) class B + class A {} b) class B inherits class A {} c) class B extends A ...
View Question