
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
12 questions
Java History Characteristics Environment

Quiz
•
University
15 questions
Java Quiz based on array

Quiz
•
University
15 questions
C++ Quiz-1

Quiz
•
University
10 questions
Objektumok kezelése, hozzáférés szabályozás, ..

Quiz
•
University
10 questions
Core Java

Quiz
•
University
15 questions
Trắc nghiệm kiến thức Java Core - Phần I

Quiz
•
University
10 questions
Quiz on OOPs- Day 1 (30-01-2025)

Quiz
•
University
10 questions
Latihan1

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University