R4RIN
Articles
Java 8
MCQS
Java MCQ Quiz Hub
Java Mcq Question Set 7
Choose a topic to test your knowledge and improve your Java skills
1. What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?
0 & 1
1 & 10
0 & 256
1 & 256
2. Which of these method waits for the thread to treminate?
isAlive()
stop()
sleep()
join()
3. Which of these method is used to explicitly set the priority of a thread?
setPriority()
makePriority()
set()
make()
4. What is synchronization in reference to a thread?
Its a method that allow to many threads to access any information require.
Its a process by which a method is able to access many different threads simultaneously.
Its a process by which many thread are able to access same shared resource simultaneously.
It's a process of handling situations when two or more threads need access to a shared resource.
5. Which of these method is used to implement Runnable interface?
runThread()
stop()
run()
stopThread()
6. Which of these interface is implemented by Thread class?
Set
Runnable
MapConnections
Connections
7. Which of these method is used to begin the execution of a thread?
startThread()
runThread()
run()
start()
8. Which of these method waits for the thread to treminate?
sleep()
join()
stop()
isAlive()
9. Which of these statement is incorrect?
A thread can be formed by a class that extends Thread class.
start() method is used to begin execution of the thread.
run() method is used to begin execution of a thread before start() method in special cases.
A thread can be formed by implementing Runnable interface only.
10. Which of these class is used to make a thread?
Thread
System
Runnable
String
11. Which of these method of Thread class is used to find out the priority given to a thread?
get()
getPriority()
getThreadPriority()
ThreadPriority()
12. Which of these method of Thread class is used to Suspend a thread for a period of time?
terminate()
sleep()
suspend()
stop()
13. Which function of pre defined class Thread is used to check weather current thread being checked is still running?
isRunning()
Alive()
Join()
isAlive()
14. What is multithreaded programming?
Its a process in which many different process are able to access same information.
Its a process in which a single process can access information from many sources.
It's a process in which two different processes run simultaneously.
It's a process in which two or more parts of same process run simultaneously.
15. Which of these are types of multitasking?
Thread based
Process based
Process and Thread based
None
16. Which of these packages contain all the Java's built in exceptions?
java.util
java.lang
java.io
java.net
17. Thread priority in Java is?
Integer
long
double
Float
18. What will happen if two thread of same priority are called to be processed simultaneously
Both of them will be executed simultaneously
Any one will be executed first lexographically
It is dependent on the operating system.
None of them will be executed
19. Which of these statements is incorrect?
By multitasking CPU's idle time is minimized, and we can take maximum use of it.
By multithreading CPU's idle time is minimized, and we can take maximum use of it.
Two thread in Java can have same priority
A thread can exist only in two states, running and blocked.
20. Which of the following can be operands of arithmetic operators?
Characters
Boolean
Both Boolean & Characters
Numeric
21. Modulus operator, %, can be applied to which of these?
Integers
Floating � point numbers
Both Integers and floating � point numbers.
None
22. With x = 0, which of the following are legal lines of Java code for changing the value of x to 1? 1. x++; 2. x = x + 1; 3. x += 1; 4. x =+ 1;
3 & 2
1 & 4
1, 2 & 3
1, 2, 3 & 4
23. Decrement operator, , decreases value of variable by what number?
1
2
3
4
24. Which of these statements are incorrect?
Assignment operators can be used only with numeric and character data type.
Assignment operators run faster than their equivalent long forms.
Assignment operators are more efficiently implemented by Java run-time system than their equivalent long forms.
None
25. Output : class increment { public static void main(String args[]) { double var1 = 1 + 5; double var2 = var1 / 4; int var3 = 1 + 5; int var4 = var3 / 4; System.out.print(var2 + " " + var4); } }
0 1
1.5 1
1 1
1.5 1.0
26. Output : class Modulus { public static void main(String args[]){double a = 25.64; int b = 25; a = a % 10; b = b % 10; System.out.println(a + " " + b); } }
5.640000000000001 5
5 5
5.640000000000001 5.0
5 5.640000000000001
27. Output : class increment { public static void main(String args[]) {int g = 3; System.out.print(++g * 8); } }
26
30
32
36
28. Output : class Output { public static void main(String args[]){ int x , y; x = 10; x++; --x; y = x++; System.out.println(x + " " + y); } }
11 13
11 12
11 11
11 10
29. Which operator is used to invert all the digits in binary representation of a number?
>>>
~
^
None
30. On applying Left shift operator, <<, on an integer bits are lost one they are shifted past which position bit?
31
32
33
34
31. Which right shift operator preserves the sign of the value?
&gt;&gt;
&gt;&gt;=
Both (a) and (b)
None
32. Which of these statements are incorrect?
The left shift operator can be used as an alternative to multiplying by 2.
The right shift operator automatically fills the higher order bits with 0.
The left shift operator, &lt;&lt;, shifts all of the bite in a value to the left specified number of times.
The right shift operator, &gt;&gt;, shifts all of the bite in a value to the right specified number of times.
33. What is the output of relational operators?
Boolean
Integer
Double
Characters
34. Which of these is returned by greater than, <, and equal to, ==, operator?
Integers
Boolean
Floating - point numbers
None
35. Which of the following operators can operate on a boolean variable?
&amp;&amp;
==
?:
All of these
36. Which of these operators can skip evaluating right hand operand?
&amp;&amp;
&amp;
!
|
37. Which of these statement is correct?
true is any non zero value and false is 0.
true and false are non numeric values.
true and false are numeric values 0 and 1.
true and false are numeric values 1 and 0.
38. Which of these have highest precedence?
*
&gt;&gt;
()
++
39. What should be expression1 evaluate to in using ternary operator as in this line? expression1 ? expression2 : expression3
Boolean
Integer
Floating point numbers
None
40. What is the value stored in x in following lines of code? int x, y, z; x = 0; y = 1; x = y = z = 8;
6
9
12
None
41. What is the order of precedence (highest to lowest) of following operators? 1. & 2. ^ 3. ?:
3 -&gt; 2 -&gt; 1
2 -&gt; 3 -&gt; 1
2 -&gt; 1 -&gt; 3
1 -&gt; 2 -&gt; 3
42. Which of these statements are incorrect?
Brackets () have highest precedence.
Addition operator, +, and subtraction operator have equal precedence.
Equal to operator has least precedence.
Division operator, /, has higher precedence than multiplication operator.
43. Which of these operators is used to allocate memory to array variable in Java?
new malloc
malloc
new
alloc
44. Which of these is an incorrect array declaration?
int arr[] = int [5] new
int arr[] = new int[5]
int arr[]arr = new int[5]
int [] arr = new int[5]
45. What will this code print? int arr[] = new int [5]; System.out.print(arr);
0
0
Garbage value
value stored in arr[0].
46. Which of these is an incorrect Statement?
Array can be initialized using comma separated expressions surrounded by curly braces.
It is necessary to use new operator to initialize an array.
Array can be initialized when they are declared.
None
47. Which of these is necessary to specify at time of array initialization?
Row
Column
Both Row and Column
None
48. When does Exceptions in Java arises in code sequence?
Compilation Time
Run Time
Can Occur Any Time
None
49. Which of these keywords is not a part of exception handling?
finally
catch
try
thrown
50. Which of these keywords must be used to monitor for exceptions?
catch
try
finally
throw
Submit