wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

FORMATIVE ASSESSMENT 2 OOPS

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.
Analyze the following program and find the output of theprogram? public class Test { public static void main(String[] args) { System.out.println(Math.min(Double.MIN_VALUE,0.0d)); } }
a)
0
b)
0.0
c)
0.0D
d)
0.0d
2.
import java.io.*; class files { public static void main(String args[]) { File obj = new File("/java/system"); System.out.print(obj.getName()); } }
a)
java
b)
system
c)
java/system
d)
/java/system
3.
What will be the output of the following Java program if input given is “abc’def/’egh”? class Input_Output { public static void main(String args[]) throws IOException{ char c; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in); do { c = (char) obj.read(); System.out.print(c); } while(c!='\''); } }
a)
abc’
b)
abcdef/’
c)
abc’def/’egh
d)
abcqfghq
4.
What is synchronization in reference to a thread?
a)
It’s a process of handling situations when two or more threads need access to a shared resource
b)
It’s a process by which many thread are able to access same shared resource simultaneously
c)
It’s a process by which a method is able to access many different threads simultaneously
d)
It’s a method that allow too many threads to access any information require
5.
Which of these method is used to explicitly set the priority of a thread?
a)
set()
b)
make()
c)
setPriority()
d)
makePriority()
6.
Which of these method waits for the thread to terminate?
a)
sleep()
b)
isAlive()
c)
join()
d)
stop()
7.
What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?
a)
0 & 256
b)
0 & 1
c)
1 & 10
d)
1 & 256
8.
Analyze the output of the following Java code. class newthread extends Thread { Thread t;newthread() { t = new Thread(this,"My Thread"); t.start(); } public void run() { try { t.join();System.out.println(t.getName()); } catch(Exception e) { System.out.print("Exception"); }}} class multithreaded_programing { public static void main(String args[]) { new newthread(); } }
a)
My Thread
b)
Thread[My Thread,5,main]
c)
Exception
d)
Runtime Error
9.
Which of this method can be used to make the main thread to be executed last among all the threads?
a)
stop()
b)
sleep()
c)
join()
d)
call()
10.
Which of these interfaces handles the event when a component is added to a container?
a)
ComponentListener
b)
ContainerListener
c)
FocusListener
d)
InputListener
11.
Which of these methods can be used to obtain the command name for invoking ActionEvent object?
a)
getCommand()
b)
getActionCommand()
c)
getActionEvent()
d)
getActionEventCommand()
12.
Which of these are integer constants defined in ActionEvent class?
a)
ALT_MASK
b)
CTRL_MASK
c)
SHIFT_MASK
d)
All of the mentioned
13.
Which of these methods can be used to obtain the coordinates of a mouse?
a)
getPoint()
b)
getCoordinates()
c)
getMouseXY()
d)
getMouseCordinates()
14.
Which of these events is generated when the window is closed?
a)
TextEvent
b)
MouseEvent
c)
FocusEvent
d)
WindowEvent
15.
Which of these interfaces define a method actionPerformed()?
a)
ComponentListener
b)
ContainerListener
c)
ActionListener
d)
InputListener