Wipro-inheritance

Wipro-inheritance

University

10 Qs

quiz-placeholder

Similar activities

QUIZ PBO R5I

QUIZ PBO R5I

University

10 Qs

QUIZ PBO R5L

QUIZ PBO R5L

University

10 Qs

Latihan1

Latihan1

University

10 Qs

OOPs Quiz

OOPs Quiz

University

10 Qs

Pretest PO-1 C

Pretest PO-1 C

University

8 Qs

Java Classes

Java Classes

University

11 Qs

Java Quiz2

Java Quiz2

University

11 Qs

Структуры С++

Структуры С++

University

11 Qs

Wipro-inheritance

Wipro-inheritance

Assessment

Quiz

Computers

University

Hard

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?