Java/Java Mcq Question Set 7 Sample Test,Sample questions

Question:
Decrement operator, , decreases value of variable by what number?

1.1

2.2

3.3

4.4


Question:
Modulus operator, %, can be applied to which of these?

1.Integers

2.Floating � point numbers

3.Both Integers and floating � point numbers.

4.None


Question:
On applying Left shift operator, <<, on an integer bits are lost one they are shifted past which position bit?

1.31

2.32

3.33

4.34


Question:
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); } }

1.0 1

2.1.5 1

3.1 1

4.1.5 1.0


Question:
Output : class increment { public static void main(String args[]) {int g = 3; System.out.print(++g * 8); } }

1.26

2.30

3.32

4.36


Question:
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); } }

1.5.640000000000001 5

2.5 5

3.5.640000000000001 5.0

4.5 5.640000000000001


Question:
Output : class Output { public static void main(String args[]){ int x , y; x = 10; x++; --x; y = x++; System.out.println(x + " " + y); } }

1.11 13

2.11 12

3.11 11

4.11 10


Question:
Thread priority in Java is?

1.Integer

2.long

3.double

4.Float


Question:
What is multithreaded programming?

1.Its a process in which many different process are able to access same information.

2.Its a process in which a single process can access information from many sources.

3.It's a process in which two different processes run simultaneously.

4.It's a process in which two or more parts of same process run simultaneously.


Question:
What is synchronization in reference to a thread?

1.Its a method that allow to many threads to access any information require.

2.Its a process by which a method is able to access many different threads simultaneously.

3.Its a process by which many thread are able to access same shared resource simultaneously.

4.It's a process of handling situations when two or more threads need access to a shared resource.


Question:
What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?

1.0 & 1

2.1 & 10

3.0 & 256

4.1 & 256


Question:
What is the order of precedence (highest to lowest) of following operators? 1. & 2. ^ 3. ?:

1.3 -> 2 -> 1

2.2 -> 3 -> 1

3.2 -> 1 -> 3

4.1 -> 2 -> 3


Question:
What is the output of relational operators?

1.Boolean

2.Integer

3.Double

4.Characters


Question:
What is the value stored in x in following lines of code? int x, y, z; x = 0; y = 1; x = y = z = 8;

1.6

2.9

3.12

4.None


Question:
What should be expression1 evaluate to in using ternary operator as in this line? expression1 ? expression2 : expression3

1.Boolean

2.Integer

3.Floating point numbers

4.None


Question:
What will happen if two thread of same priority are called to be processed simultaneously

1.Both of them will be executed simultaneously

2.Any one will be executed first lexographically

3.It is dependent on the operating system.

4.None of them will be executed


Question:
What will this code print? int arr[] = new int [5]; System.out.print(arr);

1.0

2.0

3.Garbage value

4.value stored in arr[0].


Question:
When does Exceptions in Java arises in code sequence?

1.Compilation Time

2.Run Time

3.Can Occur Any Time

4.None


Question:
Which function of pre defined class Thread is used to check weather current thread being checked is still running?

1.isRunning()

2.Alive()

3.Join()

4.isAlive()


Question:
Which of the following can be operands of arithmetic operators?

1.Characters

2.Boolean

3.Both Boolean & Characters

4.Numeric


Question:
Which of the following operators can operate on a boolean variable?

1.&&

2.==

3.?:

4.All of these


Question:
Which of these are types of multitasking?

1.Thread based

2.Process based

3.Process and Thread based

4.None


Question:
Which of these class is used to make a thread?

1.Thread

2.System

3.Runnable

4.String


Question:
Which of these have highest precedence?

1.*

2.>>

3.()

4.++


Question:
Which of these interface is implemented by Thread class?

1.Set

2.Runnable

3.MapConnections

4.Connections


Question:
Which of these is an incorrect array declaration?

1.int arr[] = int [5] new

2.int arr[] = new int[5]

3.int arr[]arr = new int[5]

4.int [] arr = new int[5]


Question:
Which of these is an incorrect Statement?

1.Array can be initialized using comma separated expressions surrounded by curly braces.

2.It is necessary to use new operator to initialize an array.

3.Array can be initialized when they are declared.

4.None


Question:
Which of these is necessary to specify at time of array initialization?

1.Row

2.Column

3.Both Row and Column

4.None


Question:
Which of these is returned by greater than, <, and equal to, ==, operator?

1.Integers

2.Boolean

3.Floating - point numbers

4.None


Question:
Which of these keywords is not a part of exception handling?

1.finally

2.catch

3.try

4.thrown


Question:
Which of these keywords must be used to monitor for exceptions?

1.catch

2.try

3.finally

4.throw


Question:
Which of these method is used to begin the execution of a thread?

1.startThread()

2.runThread()

3.run()

4.start()


Question:
Which of these method is used to explicitly set the priority of a thread?

1.setPriority()

2.makePriority()

3.set()

4.make()


Question:
Which of these method is used to implement Runnable interface?

1.runThread()

2.stop()

3.run()

4.stopThread()


Question:
Which of these method of Thread class is used to find out the priority given to a thread?

1.get()

2.getPriority()

3.getThreadPriority()

4.ThreadPriority()


Question:
Which of these method of Thread class is used to Suspend a thread for a period of time?

1.terminate()

2.sleep()

3.suspend()

4.stop()


Question:
Which of these method waits for the thread to treminate?

1.isAlive()

2.stop()

3.sleep()

4.join()


Question:
Which of these method waits for the thread to treminate?

1.sleep()

2.join()

3.stop()

4.isAlive()


Question:
Which of these operators can skip evaluating right hand operand?

1.&&

2.&

3.!

4.|


Question:
Which of these operators is used to allocate memory to array variable in Java?

1.new malloc

2.malloc

3.new

4.alloc


Question:
Which of these packages contain all the Java's built in exceptions?

1.java.util

2.java.lang

3.java.io

4.java.net


Question:
Which of these statement is correct?

1.true is any non zero value and false is 0.

2.true and false are non numeric values.

3.true and false are numeric values 0 and 1.

4.true and false are numeric values 1 and 0.


Question:
Which of these statement is incorrect?

1.A thread can be formed by a class that extends Thread class.

2.start() method is used to begin execution of the thread.

3.run() method is used to begin execution of a thread before start() method in special cases.

4.A thread can be formed by implementing Runnable interface only.


Question:
Which of these statements are incorrect?

1.Assignment operators can be used only with numeric and character data type.

2.Assignment operators run faster than their equivalent long forms.

3.Assignment operators are more efficiently implemented by Java run-time system than their equivalent long forms.

4.None


Question:
Which of these statements are incorrect?

1.The left shift operator can be used as an alternative to multiplying by 2.

2.The right shift operator automatically fills the higher order bits with 0.

3.The left shift operator, <<, shifts all of the bite in a value to the left specified number of times.

4.The right shift operator, >>, shifts all of the bite in a value to the right specified number of times.


Question:
Which of these statements are incorrect?

1.Brackets () have highest precedence.

2.Addition operator, +, and subtraction operator have equal precedence.

3.Equal to operator has least precedence.

4.Division operator, /, has higher precedence than multiplication operator.


Question:
Which of these statements is incorrect?

1.By multitasking CPU's idle time is minimized, and we can take maximum use of it.

2.By multithreading CPU's idle time is minimized, and we can take maximum use of it.

3.Two thread in Java can have same priority

4.A thread can exist only in two states, running and blocked.


Question:
Which operator is used to invert all the digits in binary representation of a number?

1.>>>

2.~

3.^

4.None


Question:
Which right shift operator preserves the sign of the value?

1.>>

2.>>=

3.Both (a) and (b)

4.None


Question:
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;

1.3 & 2

2.1 & 4

3.1, 2 & 3

4.1, 2, 3 & 4


More MCQS

  1. Java Mcq Question Set 1
  2. Java Mcq Question Set 2
  3. Java Mcq Question Set 3
  4. Java Mcq Question Set 4
  5. Java Mcq Question Set 5
  6. Java Mcq Question Set 6
  7. Java Mcq Question Set 7
  8. Java Mcq Question Set 8
  9. Java Mcq Question Set 9
  10. Java Multiple Choice Questions
  11. DATA TYPES IN JAVA
  12. Classes ,Constructor ,Methods,Inheritance
  13. Java Multiple Choice Questions.
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!