InfyTQ Polymorphism Quiz 1

Question 1

Time: 00:00:00
Examine the following class declaration? Is this valid?
Public class newclass extends maruti extends car

{

}

Yes, multiple inheritance is allowed

Yes, multiple inheritance is allowed

Yes, but it will generate warnings

Yes, but it will generate warnings

It depends on the system running it

It depends on the system running it

No, Java doesn't support multiple inheritance

No, Java doesn't support multiple inheritance

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

Please login to submit your explanation

Start

Question 2

Time: 00:00:00

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

prepinstaplacement

prepinstaplacement

prepinsta

prepinsta

Compilation error

Compilation error

Runtime error

Runtime error

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

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
In object-oriented programming, new classes can be defined by extending existing classes. This is an example of:

Encapsulation

Encapsulation

Interface

Interface

Composition

Composition

Inheritance

Inheritance

Aggregation

Aggregation

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

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
What is the name of the class that is the ancestor to every other class in Java?

object

object

class

class

Root

Root

java

java

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

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
Examine the following code:
String str = "prepinsta";

boolean switch = str instanceof String;

What value is placed in the switch?

true

true

false

false

prepinsta

prepinsta

null

null

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

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
An Overridden method is the method of ____ class and the overriding method is the method of ___ class.

sub, super

sub, super

super, super

super, super

super, sub

super, sub

sub, sub

sub, sub

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

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
What concepts come under Polymorphism in java?

Method overloading

Method overloading

Constructor overloading

Constructor overloading

Method overriding

Method overriding

All the above

All the above

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 of the following does not belong: If a class inherits from some other class, it should

Make use of the parent class’s capabilities

Make use of the parent class’s capabilities

Over-ride or add the minimum to accomplish the derived class’ purpose

Over-ride or add the minimum to accomplish the derived class’ purpose

Override all the methods of its parent class

Override all the methods of its parent class

Make sure the result “IS-A-KIND-OF” its base class

Make sure the result “IS-A-KIND-OF” its base class

Make sure the result “contains” its base class

Make sure the result “contains” its base class

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

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
Object-oriented inheritance models the

“is a kind of” relationship

“is a kind of” relationship

“has a” relationship

“has a” relationship

 “want to be” relationship

 “want to be” relationship

inheritance does not describe any kind of relationship between classes

inheritance does not describe any kind of relationship between classes

“contains” of relationship

“contains” of relationship

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

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
class prepinsta 
{
   protected void getData() 
   { 
       System.out.println("Inside prepinsta"); 
   }
}
class prepinstaplacement extends prepinsta
{
   protected void getData() 
   { 
       System.out.println("Inside prepinstaplacement"); 
   } 
}

public class exam
{
   public static void main(String[] args) 
   {
      prepinsta obj = new prepinstaplacement();
       obj.getData(); 
   } 
}

Inside prepinsta

Inside prepinsta

Inside prepinstaplacement

Inside prepinstaplacement

Compilation error

Compilation error

Runtime error

Runtime error

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!"]

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Completed

0/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects