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();
}
}
2 2
3 3
2 3
3 2
Quiz Recommendation System API Link - https://fresherbell-quiz-api.herokuapp.com/fresherbell_quiz_api
# | Quiz |
---|---|
1
Discuss
|
What is not type of inheritance?
Solution |
2
Discuss
|
Which of the following is used for implementing inheritance through an interface?
Solution |
3
Discuss
|
Which of this keyword must be used to inherit a class?
Solution |
4
Discuss
|
All classes in Java are inherited from which class?
Solution |
5
Discuss
|
What will be the output of the following Java program?
Solution |
6
Discuss
|
Which of these is correct way of inheriting class A by class B?
Solution |
7
Discuss
|
What will be the output of the following Java program?
Solution |
8
Discuss
|
What would be the result if a class extends two interfaces and both have a method with same name and signature? Lets assume that the class is not implementing that method.
Solution |
9
Discuss
|
Using which of the following, multiple inheritance in Java can be implemented?
Solution |
10
Discuss
|
Which of the following is used in implementing inheritance through class?
Solution |
# | Quiz |
Copyright © 2020 Inovatik - All rights reserved