[go: up one dir, main page]

0% found this document useful (0 votes)
25 views20 pages

Java MCQ

The document contains a series of questions and statements related to object-oriented programming concepts, including inheritance, polymorphism, encapsulation, and Java collections. It covers topics such as method overloading, method overriding, constructors, and the characteristics of various data types and collections in Java. The document appears to be structured as a quiz or study guide for understanding key programming principles.

Uploaded by

Ankur Raj Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views20 pages

Java MCQ

The document contains a series of questions and statements related to object-oriented programming concepts, including inheritance, polymorphism, encapsulation, and Java collections. It covers topics such as method overloading, method overriding, constructors, and the characteristics of various data types and collections in Java. The document appears to be structured as a quiz or study guide for understanding key programming principles.

Uploaded by

Ankur Raj Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 20

Question Text

The process of building new classes from existing one is called ______.

If an array is declared as int a[4] = {3, 0, 1, 2}, then values assigned to a[0] & a[4] will be __

Mechanism of deriving a class from another derived class is known as____

RunTime Polymorphism is achieved by ______

A property which is not true for classes is that they

The process of building new classes from existing one is called

Data members which are static

Exception handling is targeted at


Which of the following is NOT a key component of object oriented programming?

Which of these is TRUE of the relationship between objects and classes?

The Java compiler translates source code into

Which of the following is NOT a valid ‘type’ in Java?

Which of the following statements is NOT correct?

What is the different forms of Polymorphism.

What is true about method overloading.

What is true about method overriding?


What is true about an Interface

Which statement is true for constructor

public class Test { }What is the prototype of the default constructor?

The return data type of void means?

Which statements are not correct about Objects?

If an attribute is private, which methods have access to it?

What is an aggregate object?

A class can have many methods with the same name, as long as the number of parameters is
is known as:
Which of the following is NOT a valid ‘type’ in Java?

Which of the following statements is NOT correct?


What is the different forms of Polymorphism.

What is true about method overloading.

What is true about method overriding?

What is true about an Interface

Which statement is true for constructor

The return data type of void means?

Which statements are not correct about Objects?

If an attribute is private, which methods have access to it?

What is an aggregate object?


A class can have many methods with the same name, as long as the number of parameters is
is known as:

Which of these methods deletes all the elements from invoking collection?
What is Collection in Java?
Which of the following is a part of the Java Collections Framework?
Which is the root interface of the Java Collection framework hierarchy?
Which collection does not allow duplicate elements?
Which collection allows you to retrieve elements in the order they were inserted?
Which class is a resizable array implementation?
Which collection ensures that elements are processed in first-in-first-out (FIFO) order?
Which of the following collections is sorted by its natural ordering?
Choice 1
Polymorphism

3, 2

Polymorphism

friend function

are removed from memory when not in use.

Structure.

cannot be assigned a value

Run-time error
Inheritance

A class is an instance of an object.

machine code

void

We can use a new operator on String to create a


"String" object.

Method overloading

Overloaded methods MUST change the argument list

You can’t override a method marked public and make it


protected.
You can’t mark an interface as final.

A constructor has the same name as the class name

Test( )

A void area in memory is returned so that you can


populate it.

An Object is an instance of a class

Only those defined in the same class.

An object instance that has only static methods.

Method Overloading
void

We can use a new operator on String to create a


"String" object.
Method overloading

Overloaded methods MUST change the argument list


You can’t override a method marked public and make it
protected.

You can’t mark an interface as final.

A constructor has the same name as the class name


A void area in memory is returned so that you can
populate it.

An Object is an instance of a class

Only those defined in the same class.

An object instance that has only static methods.

Method Overloading

clear()
A group of objects
ArrayList
Collection
List
HashSet
LinkedList
HashSet
HashMap
Answer Choice 2 Answer Choice 3 (optional)
Structure Inheritance

0, 2 3, 0

Single Inheritance Multilevel Inheritance

function Overriding operator overloading

permit data to be hidden from bring together all aspects of


other classes. an entity in one place.

Inheritance. Polymorphism

cannot be defined in a
can only be used in static functions Union

Compile time error Logical error


Encapsulation Polymorphism

An object is the ancestor of its An object is an instance of a


subclass. class.

Assembly code Byte code

int Integer

Variables of type "int" can


We can use the new operator on int be assigned a value just
to create an "int" object. after being declared.

Method overriding through Method overriding through


inheritance the Java interface

Overloaded methods CAN change Overloaded methods CAN


the return type change the access modifier

You cannot override a method You cannot override a


marked final method marked static
An Interface cannot extend
anything but another
Interface variables must be static. interfaces

A class can contain more


A constructor should not have a than one constructor, So it
return type can be overloaded

Test(void) public Test( )

No data type is returned. void is not a valid data type.

Objects can access both instance All classes extend the


and static data Object class

Only static methods in the same Only instance methods in


class. the same class.

An object instance that has only An object instance that


primitive attributes. contains other objects.

Method Invocating Method Overriding


int Integer
Variables of type "int" can
We can use the new operator on int be assigned a value just
to create an "int" object. after being declared.
Method overriding through Method overriding through
inheritance the Java interface

Overloaded methods CAN change Overloaded methods CAN


the return type change the access modifier
You cannot override a method You cannot override a
marked final method marked static
An Interface cannot extend
anything but another
Interface variables must be static. interfaces
A class can contain more
A constructor should not have a than one constructor, So it
return type can be overloaded

No data type is returned. void is not a valid data type.


Objects can access both instance All classes extend the
and static data Object class
Only static methods in the same Only instance methods in
class. the same class.
An object instance that has only An object instance that
primitive attributes. contains other objects.

Method Invocating Method Overriding

reset() delete()
A group of classes A group of interfaces
Array int[]
Root Collections
Set Map
TreeMap LinkedHashMap
ArrayList HashSet
LinkedHashSet LinkedList
TreeMap LinkedHashMap
Answer Choice 4 (optional) Answer
Cascading Inheritance

0, 4 3, 0

Message Passing Multilevel Inheritance

function overloading function Overriding

Can closely model objects in the real bring together all aspects of
world. an entity in one place.

Template. Inheritance.

can only be used in static


can be accessed outside the class functions

All of the above Run-time error


Parallelism Parallelism

An object is the descendant of its An object is an instance of a


superclass. class.

JVM code Byte code

static static

Variables of type "String" can be We can use the new operator


assigned a value just after being on int to create an "int"
declare object.

All Of the Above All Of the Above

All Of the Above All Of the Above

All Of the Above All Of the Above


All Of the Above All Of the Above

All Of the Above All Of the Above

public Test(void) Test( )

None of the above No data type is returned.

Objects do not permit


Objects do not permit encapsulation encapsulation

Only those defined in the


Only classes in the same package. same class.

An object that has only primitive An object instance that


attributes and instances methods. contains other objects.

Method Labeling Method Invocating


static static
Variables of type "String" can be We can use the new operator
assigned a value just after being on int to create an "int"
declare object.
All Of the Above All Of the Above

All Of the Above All Of the Above

All Of the Above All Of the Above

All Of the Above All Of the Above

All Of the Above All Of the Above

None of the above No data type is returned.


Objects do not permit
Objects do not permit encapsulation encapsulation
Only those defined in the
Only classes in the same package. same class.
An object that has only primitive An object instance that
attributes and instances methods. contains other objects.

Method Labeling Method Overloading

refresh() clear()
None of the mentioned A group of objects
String ArrayList
List/Set Collection
All of the above Set
PriorityQueue LinkedHashMap
ArrayDeque ArrayList
PriorityQueue LinkedList
Hashtable TreeMap

You might also like