
Wipro-inheritance

Quiz
•
Computers
•
University
•
Hard
Karthika IT
Used 1+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
In order to restrict a variable of a class from inheriting to a subclass, how variable should be declared?
Private
Protected
Public
Both private and public
2.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
A class member declared protected becomes member of subclass of which type?
protected member
private member
static member
public member
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following?
class A
{
public int i;
private int j;
}
class B extends A
{
void display()
{
super.j=super.i+1;
System.out.println(super.i+" "+super.j);
}
}
class inheritance
{
Public static void main(String args[])
{
B obj=newB();
obj.i=1;
obj.j=2;
obj.display();
}
}
2 2
3 3
Runtime error
Compilation error
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Determine the output
Class A{
public void printName(){
System.out.println("Name-A");
}
}
class B extendsA{
public oid printName(){
System.out.println("Name-B");
}
}
class C extendsA{
public void printName(){
System.out.println("Name-C");
}
}
public class Test{
public static void main (String[] args){
B b=new B();
C c=new C();
b = c;
newPrint(b);
}
public static void newPrint(A a){
a.printName();
}
}
Name-B
Compilation error
Run time error
Name-A
5.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Inheritance relationship in Java language is
Association
Is-A
Has-A
None
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of this program?
class A
{
public int i;
protected int j;
}
class B extends A
{
int j;
void display()
{
super.j=3;
System.out.println(i+" "+ j);
}
}
class Output
{
public static void main(String args[])
{
B obj=new B();
obj.i=1;
obj.j=2;
obj.display();
}
}
1 2
2 1
1 3
3 1
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the result of compiling and running the following code?
class Base{
public Base(){
System.out.print("Base");
}
}
public class Derived extends Base{
public Derived(){
this("Exam veda");
System.out.print("Derived");
}
public Derived(String s){
System.out.print(s);
}
public static void main(String[] args){
new Derived();
}
}
Exam veda Derived
Exam veda Base Derived
Base Exam veda Derived
Exam veda Derived Base
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
Talent Next Java MCQ-1

Quiz
•
University
14 questions
Java Operators

Quiz
•
University
10 questions
java quiz on Encapsulation and Abstraction

Quiz
•
University
10 questions
Динамические библиотеки

Quiz
•
University
10 questions
Temel Java Bilgisi Ölçme Testi

Quiz
•
University
15 questions
java programming

Quiz
•
University
13 questions
Wipro PRP - 15th June

Quiz
•
University
6 questions
1150 Java Basics

Quiz
•
University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Computers
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University