0% found this document useful (0 votes)
105 views7 pages

R.M.D Engineering College Department of Computer Science and Engineering Cs8383 Object Oriented Programming Laboratory Multiple Choice Questions

The document contains 30 multiple choice questions related to object oriented programming and Java concepts like classes, objects, inheritance, exceptions, generics, multithreading and event handling. It tests knowledge on basic Java features, OOP principles and commonly used classes in core Java packages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views7 pages

R.M.D Engineering College Department of Computer Science and Engineering Cs8383 Object Oriented Programming Laboratory Multiple Choice Questions

The document contains 30 multiple choice questions related to object oriented programming and Java concepts like classes, objects, inheritance, exceptions, generics, multithreading and event handling. It tests knowledge on basic Java features, OOP principles and commonly used classes in core Java packages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

R.M.

D ENGINEERING COLLEGE
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CS8383 OBJECT ORIENTED PROGRAMMING LABORATORY
MULTIPLE CHOICE QUESTIONS

1. What will be printed as the output of the following program?


public class testincr
{
public static void main(String args[])
{
int I = 0;
I = i++ + I;
System.out.println(“Value of I is: “ +i);
}
}
a) Value of I is: 0
b) Value of I is: 1
c) Value of I is: 2
d) Value of I is: 3
Answer: b

2.What is the output of the following program?


public class testmeth
{
static int i = 1;
public static void main(String args[])
{
System.out.print(i+" , ");
m(i);
System.out.println(i);
}
public static void m(int i)
{
i += 2; } }
a) 1, 3
b) 3, 1
c) 1, 0
d) 1, 1
Answer: d

3.How many primitive data types are there in Java?


a) 9
b) 7
c) 8
d) 6
Answer: c

4.What is true about constructor?


a) It can contain return type
b) It can take any number of parameters
c) It can have any non access modifiers
d) Constructor cannot throw an exception
Answer: b

5.Which of the following is a valid declaration of an object of class Box?


a) Box obj = new Box();
b) Box obj = new Box;
c) obj = new Box();
d) new Box obj;
Answer: a

6.Which of these is a mechanism for naming and visibility control of a class and its content?
a) Object
b) Packages
c) Interfaces
d) None of the Mentioned
Answer: b

7. What is the error in the following code?


class Test
{
abstract void display( );
}
A) No error
B) Method display( ) should be declared as static
C) Test class should be declared as abstract
D) Test class should be declared as public
Answer: C

8.The fields in an interface are implicitly specified as


a) both static and final
b) static only
c) final only
d) neither static nor final
Answer: a
9.Which of these can be used to fully abstract a class from its implementation?
a) Objects
b) Packages
c) Interfaces
d) None of the Mentioned
Answer: c

 10. Which of these class is superclass of every class in Java?


a) String class
b) Object class
c) Abstract class
d) ArrayList class
Answer: b

11.Which of these keywords can be used to prevent inheritance of a class?


a) super
b) constant
c) class
d) final
Answer: d

12.A class member declared protected becomes a member of subclass of which type?
a) public member
b) private member
c) protected member
d) static member
Answer: b

13.Which of these is an incorrect statement?


a) String objects are immutable, they cannot be changed
b) String object can point to some other reference of String variable
c) StringBuffer class is used to store string in a buffer for later use
d) None of the mentioned
Answer: c

14.Which among the following is not a method of Throwable class?


a) public String getMessage()
b) publicThrowablegetCause()
c) public char toString()
d) public void printStackTrace()
Answer: c

15.Which class is used to handle the input and output exceptions?


a) InputOutput
b) InputOutputExceptions
c) IOExceptions
d) ExceptionsIO
Answer: c

16.Why do we use finally block?


a) To execute the block if exception occurred
b) To execute a code when exception is not occurred
c) To execute a code whenever required
d) To execute a code with each and every run of program
Answer: d

17.Which among the following is true for class exceptions?


a) Only base class can give rise to exceptions
b) Only derived class can give rise to exceptions
c) Either base class or derived class may produce exceptions
d) Both base class and derived class may produce exceptions
Answer: d

18.Which among the following is a serialization descriptor for any class?


a) StreamClass
b) ObjectStreamClass
c) ObjectStream
d) StreamObjectClass
Answer: b

19.If both base and derived class caught exceptions ______________


a) Then catch block of derived class must be defined before base class
b) Then catch block of base class must be defined before the derived class
c) Then catch block of base and derived classes doesn’t matter
d) Then catch block of base and derived classes are not mandatory to be defined
Answer: a

20.Which of these statements is incorrect?


a) By multithreading CPU idle time is minimized, and we can take maximum use of it
b) By multitasking CPU idle time is minimized, and we can take maximum use of it
c) Two thread in Java can have the same priority
d) A thread can exist only in two states, running and blocked
Answer: d

21.What is the output of the following program?

public class genericstack <E>


{
Stack <E> stk = new Stack <E>();
public void push(E obj)
{
stk.push(obj);
}
public E pop()
{
E obj = stk.pop();
return obj;
}
}
class Output
{
public static void main(String args[])
{
genericstack <String> gs = new genericstack<String>();
gs.push("Hello");
System.out.println(gs.pop());
}
}
a. H

b. Hello

c. Runtime Error

d. Compilation Error
Answer: b

22. What is the name of the thread in the following Java Program?
classmultithreaded_programing
{
publicstaticvoid main(Stringargs[])
{
Thread t =Thread.currentThread();
System.out.println(t);
}
}
a) main
b) Thread
c) System
d) None of the mentioned
Answer: a

23.Which of these are types of multitasking?


a) Process based
b) Thread based
c) Process and Thread based
d) None of the mentioned
Answer: c
24.Which of these method of Thread class is used to Suspend a thread for a period of time?
a) sleep()
b) terminate()
c) suspend()
d) stop()
Answer: a

25.What will happen if two thread of the same priority are called to be processed
simultaneously?
a) Anyone will be executed first lexographically
b) Both of them will be executed simultaneously
c) None of them will be executed
d) It is dependent on the operating system
Answer: d

26.Which of these packages contains all the event handling interfaces?


a) java.lang
b) java.awt
c) java.awt.event
d) java.event
Answer: c

27.Which of these is a superclass of all Adapter classes?


a) Applet
b) ComponentEvent
c) Event
d) InputEvent
Answer: a

28.What is an event in delegation event model used by Java programming language?


a) An event is an object that describes a state change in a source
b) An event is an object that describes a state change in processing
c) An event is an object that describes any change by the user and system
d) An event is a class used for defining object, to create events
Answer: a

29. Which of these methods are used to register a keyboard event listener?


a) KeyListener()
b) addKistener()
c) addKeyListener()
d) eventKeyboardListener()
Answer: c
30.Which of these methods can be used to determine the type of event?
a) getID()
b) getSource()
c) getEvent()
d) getEventObject()
Answer: a

You might also like