Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

InfyTQ Polymorphism Quiz 2

Question 1

Time: 00:00:00
If you have the following classes. Which of the following constructors would be valid for Point3D?
public class Point2D {
  public int x;
  public int y;
  public Point2D() {}
  public Point2D(int x,int y) {
     this.x = x;
     this.y = y;
  }
 // other methods
}

public class Point3D extends Point2D
{
  public int z;
  // other code
}

 

  1. public Point3D() {}

  2. public Point3D(int x, int y, int z)


    {

       super(x,y);

       this.z = z;

    }

III. public Point3D(int x, int y)

     {

        this.x = x;

        this.y = y;

        this.z = 0;

     }

II only

II only

III only

III only

I, II, and III

I, II, and III

I and II only

I and II only

I only

I only

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
Which statement is true regarding an object?

An object is what classes instantiated are from

An object is what classes instantiated are from

An object is an instance of a class

An object is an instance of a class

An object is a variable

An object is a variable

An object is a reference to an attribute

An object is a reference to an attribute

An object is not an instance of a class

An object is not an instance of a class

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
interface prepinsta 
{
   void myMethod(); 
   void getInfo(); 
}
abstract class placement implements prepinsta
{
   void getData() 
   { 
       System.out.println("prepinsta"); 
   } 
}

public class exam extends placement
{
   public void myMethod() 
   { 
       System.out.println("prepinstaplacement"); 
   } 
   public void getInfo() 
   { 
       System.out.println("placement"); 
   } 
   
   public static void main(String[] args) 
   { 
       placement obj = new exam(); 
       obj.getInfo(); 
   } 
}

placement

placement

Compilation error

Compilation error

Runtime error

Runtime error

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
Examine the following code. It can be said that the class Banana _____ attributes from the class public class banana extends fruit ()

{

}

Fruit

Fruit

Deletes

Deletes

Copies

Copies

Edits

Edits

Inherits

Inherits

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
Polymorphism supports _____, which is several methods with the same name but different arguments

Overriding

Overriding

Overclocking

Overclocking

Overloading

Overloading

Overarching

Overarching

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
Which feature comes under compile time polymorphism?

Method overloading

Method overloading

Constructor overloading

Constructor overloading

Method overriding

Method overriding

Both A and B

Both A and B

Both A and C

Both A and C

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
Which one is the language that does not support polymorphism but support classes?

C#

C#

Java

Java

C++

C++

Ada

Ada

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
Which function shows polymorphism

Inline function

Inline function

Undefined functions

Undefined functions

Virtual function

Virtual function

Class member functions

Class member functions

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
Is Polymorphism  possible in C language

No

No

Yes

Yes

both A&B

both A&B

none of these

none of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
If two classes derive one base class and redefine a function of the base class, also overload some operators inside the body of the class. Among these two things of function and operator overloading, the polymorphism is used where?

Either function overloading or operator overloading because polymorphism can be applied only once in a program

Either function overloading or operator overloading because polymorphism can be applied only once in a program

Operator overloading only

Operator overloading only

Function overloading only

Function overloading only

Both of these are using polymorphism

Both of these are using polymorphism

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]