Wipro-inheritance

Wipro-inheritance

University

10 Qs

quiz-placeholder

Similar activities

PYTHON BASICS PART 1

PYTHON BASICS PART 1

University

10 Qs

Visual Basic 2010

Visual Basic 2010

8th Grade - University

10 Qs

DSA quiz 3 set 1

DSA quiz 3 set 1

University

10 Qs

Types of Mass Media

Types of Mass Media

10th Grade - Professional Development

11 Qs

IP-Com3 - Clase 2

IP-Com3 - Clase 2

University

12 Qs

Python Quiz

Python Quiz

University

15 Qs

2018Quiz1INT202

2018Quiz1INT202

University

13 Qs

Java Quiz 4

Java Quiz 4

University

15 Qs

Wipro-inheritance

Wipro-inheritance

Assessment

Quiz

Computers

University

Practice Problem

Hard

Created by

Karthika IT

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers