0% found this document useful (0 votes)
29 views

Etc Programming For Problem Solving

This document contains a quiz with multiple choice questions about object-oriented programming concepts in Java like inheritance, polymorphism, abstraction, encapsulation, exceptions, interfaces and abstract classes. It tests the understanding of these concepts through short questions and answers.

Uploaded by

Ayush Mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Etc Programming For Problem Solving

This document contains a quiz with multiple choice questions about object-oriented programming concepts in Java like inheritance, polymorphism, abstraction, encapsulation, exceptions, interfaces and abstract classes. It tests the understanding of these concepts through short questions and answers.

Uploaded by

Ayush Mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Q 1) Inheritance provide :

A) code re-usability B) functions


C) polymorphism D) None of these
Q 2) What the inheritance is representing?
A) Inheritance is a way of
representing classes.
B) Inheritance is a way of
representing real-world
relationships.
C) Inheritance is a way of
representing objects relationships.
D) None of these
Q 3) What do you mean by inheritance?
A) Inheritance is a mechanism in
which make copy of one object.
B) Inheritance is a mechanism in
which any class acquires the
object capability.
C) Inheritance is a mechanism in
which one class acquires the
property of another class.
D) None of these
Page 1 of 8
FOURTH SEMESTER ELECTRONICS & TELECOMMUNICATION(CBCS) B.TECH - Roll Number :
PROGRAMMING FOR PROBLEM SOLVING

.
.
.
Q 4) What do you mean by subclass?
A) The parent class of a class is
called as subclass.
B) Any class can be called as
subclass.
C) The hierarchy of classes is called
subclass.
D) An inherited class is called a
subclass of its parent class or
super class.
Q 5) Which is not a type of inheritance?
A) multiple B) multilevel
C) single D) double
Q 6) What do you mean by single inheritance?
A) Inheritance where subclasses
inherit the features of one
superclass. A class acquires the
properties of another class.
B) Inheritance where subclasses
inherit the features of two
superclass.
C) Inheritance where subclasses
inherit the features of three
superclass.
D) Inheritance where subclasses
inherit the features of four
superclass.
Q 7) What do you mean by multiple inheritance?
A) Inheritance where one class can
have one superclass and inherit
features from all parent classes.
B) Inheritance where one class can
have more than one superclass
and inherit features from all parent
classes.
C) Inheritance where n classes can
have n superclasses and inherit
features from all parent classes.
D) None of these
Q 8) What is hierarchical inheritance?
A) The inheritance where one class
serves as a superclass (base
class) for more than one sub class.
B) The inheritance where one class
serves as a superclass (base
class) for one sub class.
C) The inheritance where a class
serves as a superclass and
exactly one class.
D) None of these
Q 9) Which is the correct general form of defining a derived class ?
A) class SubClass: SuperClass { //
subclass members };
B) class SubClass: visibility
SuperClass { // subclass
members };
C) class SubClass: D) None of these
Page 2 of 8
FOURTH SEMESTER ELECTRONICS & TELECOMMUNICATION(CBCS) B.TECH - Roll Number :
PROGRAMMING FOR PROBLEM SOLVING

.
.
.
Q 10) What is the use of super keyword?
A) It refers to class objects. B) It refers to subclasses.
C) It refers to superclass (parent)
objects.
D) None of these
Q 11) When does Exceptions in Java arises in code sequence?
A) Run Time B) Compilation Time
C) Can Occur Any Time D) None of the mentioned
Q 12) Which of these keywords is not a part of exception handling?
A) try B) finally
C) thrown D) catch
Q 13) Which of these keywords is used to manually throw an exception?
A) try B) finally
C) throw D) catch
14) The closest common ancestor of RuntimeException, Error, IOException and
classNotFoundException is:
Q
A) Object B) Exception
C) Throwable D) Catchable
Q 15) Which of the following statements is true about Java`s finally block?
A) The finally block is only executed if
an exception is thrown in the try
block
B) The finally block is only executed if
an exception is thrown in the catch
block
C) The finally block is only executed if
an exception is not thrown in the
try or catch block
D) The finally block is executed
regardless of whether an
exception is thrown in the try or
catch block
Q 16) A JVM level problem that terminates the current runtime is a subtype of:
A) RuntimeException B) Exception
C) FatalException D) Error
Q 17) In which of the following package Exception class exist?
A) java.file B) java.lang
C) java.io D) java.util
Q 18) Which exception is thrown when divide by zero statement executes?
A) NumberFormatException B) NullPointerException
C) ArithmeticException D) None of these
Page 3 of 8
FOURTH SEMESTER ELECTRONICS & TELECOMMUNICATION(CBCS) B.TECH - Roll Number :
PROGRAMMING FOR PROBLEM SOLVING

.
.
.
19) Where are the following four methods commonly used?
1) public void add(Component c)
2) public void setSize(int width,int height)
3) public void setLayout(LayoutManager m)
4) public void setVisible(boolean)
Q
A) Graphics class B) Component class
C) Both A & B D) None of the above
Q 20) Which method executes only once in swing
A) start() method B) init() method
C) stop() method D) destroy() method
Q 21) Which keyword is used to declare an interface ?
A) interface B) abstract
C) class D) implements
Q 22) Which kind of methods does an interface contain by default?
A) static B) Abstract
C) final D) void
Q 23) When you can call a class as abstract class?
A) A class which is declared with the
abstract keyword ,we call it as an
abstract class
B) A class which is declared with the
virtual keyword ,we call it as an
abstract class
C) A class which is declared with the
interface keyword ,we call it as an
abstract class
D) None of these
Q 24) Which of the following statement(s) are true about the interface?
A) An interface can only contain
abstract methods.
B) We can define a method in an
interface.
C) Both A & B D) None of these
Q 25) What is the syntax used to declare an abstract class ?
A) class A{} B) abstract class A{}
C) class abstract A{} D) None of these
Q 26) Which method is declared as abstract but does not have implementation ?
A) Abstract Interface B) Thread
C) List Abstract D) None of these
Page 4 of 8
FOURTH SEMESTER ELECTRONICS & TELECOMMUNICATION(CBCS) B.TECH - Roll Number :
PROGRAMMING FOR PROBLEM SOLVING

.
.
.
Q 27) Which of the following is not a correct statement?
A) Every class containing abstract
method must be declared abstract.
B) Abstract class defines only the
structure of the class not its
implementation.
C) Abstract class can be instantiated
by using new operator.
D) Abstract class can be inherited.
Q 28) An abstract class in usually contains:
A) one or more abstract methods B) one or more constructors
C) one or more abstract variables D) one or more constants
29) If a class inheriting an abstract class does not define all of its function then it
will be known as?
Q
A) non-static B) abstract
C) static D) volatile
Q 30) Which of these access specifiers can be used for an interface?
A) public B) protected
C) private D) None of these
Q 31) Which statement is true about Java?
A) Java is a sequence-dependent
programming language
B) Java is a code dependent
programming language
C) Java is a platform-dependent
programming language
D) Java is a platform-independent
programming language
Q 32) Which component is used to compile, debug and execute the java programs?
A) JRE B) JIT
C) JDK D) JVM
Q 33) Which one of the following is not a Java feature?
A) Object-oriented B) Use of pointers
C) Portable D) Dynamic and Extensible
Q 34) Which of these cannot be used for a variable name in Java?
A) identifier & keyword B) identifier
C) keyword D) none of the mentioned
Page 5 of 8
FOURTH SEMESTER ELECTRONICS & TELECOMMUNICATION(CBCS) B.TECH - Roll Number :
PROGRAMMING FOR PROBLEM SOLVING
.
.
.
35) What will be the output of the following Java code?
class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}
Q
A) 32 B) 33
C) 24 D) 25
Q 36) Which of the following is not an OOPS concept in Java?
A) Polymorphism B) Inheritance
C) Compilation D) Encapsulation
37) . What will be the output of the following Java program?
class output {
public static void main(String args[])
{
double a, b,c;
a = 3.0/0;
b = 0/4.0;
c=0/0.0;
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
Q
A)

You might also like