Congrats !!! You Have Successfully Completed The Session:) ..
Congrats !!! You Have Successfully Completed The Session:) ..
Congrats !!! You Have Successfully Completed The Session:) ..
/ Inheritance / Explore
×
CONGRATS!!!
Congrats !!! You have successfully completed the session :) ... TOTAL SCORE: 80.0%
ANSWERED
PROBLEM POINTS
CORRECTLY
Check
1
When do we use Abstract class? 1.0 Correct Answer
Answer
2
What is the output of this program? class A {
final int a = 15;
}
class B Check
1.0 Correct Answer
extends A {
... Answer
ANSWERED
PROBLEM POINTS
CORRECTLY
class A {
final int a = 15;
class B extends A {
B b = new C();
System.out.print(b.a);
}
}
1) 15
2) 20
3) 30
4) compilation error
3
What is the output of the below program? class Main {
public static void Check
1.0 Correct Answer
print(Integer i... Answer
class Main {
System.out.println(2*i);
}
public static void print(String s) {
System.out.println(s);
}
public static void main(String[] args) {
print("5");
}
}
1) 5
2) 10
3) compilation error
4) null
ANSWERED
PROBLEM POINTS
CORRECTLY
4
What should be filled in the 13th line to make the code compilable? 1.class Check
0.0 Wrong Answer
A {
2. A(Integ... Answer
What should be filled in the 13th line to make the code compilable?
1.class A {
2. A(Integer a){}
3.
4. A(){}
5.}
6.
7.class B extends A {
8. B(){}
9. B(Integer a) {
10. super(a);
11. }
12. void test(){
14. }
15. }
1) A a = new B(a);
2) A a = new B("3");
4) A a = new B(5);
5
What is the output of this program? abstract class TestAbstract {
String Check
1.0 Correct Answer
name;
String ... Answer
ANSWERED
PROBLEM POINTS
CORRECTLY
}
abstract void display();
}
public static void main(String args[]) {
t.display();
}
}
1) Program will compile and execute successfully and prints the output.
4) Compilation error occurs as the abstract class TestAbstract contains a non-abstract method.
Check
6
A variable is declared as ______ to restrict the sub class from inheriting it. 1.0 Correct Answer
Answer
A variable is declared as ______ to restrict the sub class from inheriting it.
1) protected
2) private
3) public
4) static
7
What is the output of this program? class A {
final int a = 15;
}
class B Check
1.0 Correct Answer
extends A {
... Answer
ANSWERED
PROBLEM POINTS
CORRECTLY
class A {
final int a = 15;
class B extends A {
C c = new B();
System.out.print(c.a);
}
}
1) 15
2) 20
3) 30
4) Compilation error
Check
8
In Java, Multiple inheritance are implemented by_________. 1.0 Correct Answer
Answer
1) Interfaces
2) Multithreading
3) Protected methods
4) Private methods
9
Consider the following situation and answer the question There are two Check
0.0 Wrong Answer
classes, Class A and Class... Answer
ANSWERED
PROBLEM POINTS
CORRECTLY
Class B extends A.
Both have a method with same name but with different signatures (arguments).
1) overridden
2) overloaded
4) static
10
What happens when the program is executed? class A {
public void Check
1.0 Correct Answer
method() {
Syste... Answer
class A {
public void method() {
System.out.println("Hi i am A");
}
}
public class B extends A {
System.out.println("Hi i am B");
}
public static void main(String args[]){
B b = new B();
b.method();
}
}
11
What is the output of this program? class A {
final int method() {
Check
1.0 Correct Answer
return 100;
... Answer
ANSWERED
PROBLEM POINTS
CORRECTLY
class A {
final int method() {
return 100;
}
}
public class B extends A {
return 50;
}
public static void main(String[] args) {
A a = new B();
System.out.println(a.method());
}
}
1) 100
2) 50
3) compilation error
4) runtime error
Check
12
Which of the following cannot be overriden? 1.0 Correct Answer
Answer
1) class methods
2) protected methods
3) default method
4) public methods
5) static methods
13
What is the output of this program? class Test {
public static void Check
1.0 Correct Answer
print(Integer i) {
... Answer
ANSWERED
PROBLEM POINTS
CORRECTLY
class Test {
System.out.println(2*i);
}
public void print(String s) {
System.out.println(s);
}
public static void main(String args) {
print("5");
}
}
1) 5
2) 10
3) compilation error
Check
14
In Java, which of the following keywords prevent method overriding? 1.0 Correct Answer
Answer
1) static
2) constant
3) protected
4) final
Check
15
All classes in Java inherit ________ class. 0.0 Wrong Answer
Answer
ANSWERED
PROBLEM POINTS
CORRECTLY
1) java.lang.class
2) java.class.inherited
3) java.class.object
4) java.lang.Object
Go to course
×
Test Case Details
×
Calendar
No Content
Close
×
Notification
Close
×
Enrolment Schedule
Close
X
×
×
Message
Close
CANCEL
OK