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();
}
}
0
1
2
Compilation Error
Quiz Recommendation System API Link - https://fresherbell-quiz-api.herokuapp.com/fresherbell_quiz_api
| # | Quiz |
|---|---|
|
1
Discuss
|
If super class and subclass have same variable name, which keyword should be used to use super class?
Solution |
|
2
Discuss
|
Which of the following is used in implementing inheritance through class?
Solution |
|
3
Discuss
|
Does Java support multiple level inheritance?
Solution |
|
4
Discuss
|
What will be the output of the following Java program?
Solution |
|
5
Discuss
|
Which of the following is used for implementing inheritance through an interface?
Solution |
|
6
Discuss
|
Using which of the following, multiple inheritance in Java can be implemented?
Solution |
|
7
Discuss
|
A class member declared protected becomes a member of subclass of which type?
Solution |
|
8
Discuss
|
All classes in Java are inherited from which class?
Solution |
|
9
Discuss
|
Static members are not inherited to subclass.
Solution |
|
10
Discuss
|
What is not type of inheritance?
Solution |
| # | Quiz |
Copyright © 2020 Inovatik - All rights reserved