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)
}
}
1 2
2 1
Runtime Error
Compilation Error
Quiz Recommendation System API Link - https://fresherbell-quiz-api.herokuapp.com/fresherbell_quiz_api
# | Quiz |
---|---|
1
Discuss
|
What will be the output of the following Java program?
Solution |
2
Discuss
|
Which of this keyword must be used to inherit a class?
Solution |
3
Discuss
|
What will be the output of the following Java program?
Solution |
4
Discuss
|
A class member declared protected becomes a member of subclass of which type?
Solution |
5
Discuss
|
Which of these is correct way of inheriting class A by class B?
Solution |
6
Discuss
|
All classes in Java are inherited from which class?
Solution |
7
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 |
8
Discuss
|
Which of the following is used for implementing inheritance through an interface?
Solution |
9
Discuss
|
Using which of the following, multiple inheritance in Java can be implemented?
Solution |
10
Discuss
|
Static members are not inherited to subclass.
Solution |
# | Quiz |
Copyright © 2020 Inovatik - All rights reserved