Java Operators and Control Statements Mcqs
Our collections of Multiple choice questions and answers focuses on study of Java Operators and Control Statements. These questions are chosen from a collection of most authoritative and best reference books on Java. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate jJava Operators and Control Statements topic comprehensively.
Java Programming Mcqs
- Data Types Variables and Arrays Mcqs
- Exception Handling in Java Mcqs
- Interfaces and Packages Mcqs
- Java Classes and Methods Mcqs
- Java Event Handling Mcqs
- Java Inheritance Mcqs
- Java IO and Applets Mcqs
- java lang and java io Mcqs
- Java Language Fundamentals Mcqs
- Java Operators and Control Statements Mcqs
- java utilities Mcqs
- Miscellaneous Topics in Java Mcqs
- Multithreading in Java Mcqs
- Serialization and Networking Mcqs
- Session Management and JSP and Servlet Mcqs
- String Handling
Computer MCQS
Sciences MCQS
2.
Which of these statements are incorrect?
The left shift operator, <<, shifts all of the bits in a value to the left specified number of times
The right shift operator, >>, shifts all of the bits in a value to the right specified number of times
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
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
3.
What is the output of this program?
class bitwise_operator
{
public static void main(String args[])
{
int var1 = 42;
int var2 = ~var1;
System.out.print(var1 + " " + var2);
}
}
class bitwise_operator
{
public static void main(String args[])
{
int var1 = 42;
int var2 = ~var1;
System.out.print(var1 + " " + var2);
}
}
42 42
43 43
42 -43
42 43
4.
What is the output of this program?
class bitwise_operator
{
public static void main(String args[])
{
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d);
}
}
class bitwise_operator
{
public static void main(String args[])
{
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d);
}
}
7 2
7 7
7 5
5 2
5.
What is the output of relational operators?
Integer
Boolean
Characters
Double
7.
Which of the following operators can operate on a boolean variable? 1. &&
2. ==
3. ?:
4. +=
1. &&
2. ==
3. ?:
4. +=
3 & 2
1 & 4
1, 2 & 4
1, 2 & 3
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
8.
Which of these operators can skip evaluating right hand operand?
!
|
&
&&
9.
Which of these statements is correct?
True and false are numeric values 1 and 0
True and false are numeric values 0 and 1
True is any non zero value and false is 0
True and false are non numeric values
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
10.
What is the output of this program?
class Relational_operator
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
System.out.print(var1 > var2);
}
}
class Relational_operator
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
System.out.print(var1 > var2);
}
}
1
0
True
False
11.
What is the output of this program?
class bool_operator
{
public static void main(String args[])
{
boolean a = true;
boolean b = !true;
boolean c = a | b;
boolean d = a & b;
boolean e = d ? b : c;
System.out.println(d + " " + e);
}
}
class bool_operator
{
public static void main(String args[])
{
boolean a = true;
boolean b = !true;
boolean c = a | b;
boolean d = a & b;
boolean e = d ? b : c;
System.out.println(d + " " + e);
}
}
false false
frue ture
frue false
false true
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
12.
Which of these have highest precedence?
()
++
*
>>
13.
What should be expression1 evaluate to in using ternary operator as in this line? expression1 ? expression2 : expression3
expression1 ? expression2 : expression3
Integer
Boolean
None of the mentioned
14.
What is the value stored in x in following lines of code? int x, y, z;
x = 0;
y = 1;
x = y = z = 8;
int x, y, z;
x = 0;
y = 1;
x = y = z = 8;
0
1
9
8
15.
What is the order of precedence (highest to lowest) of following operators? 1. &
2. ^
3. ?:
1. &
2. ^
3. ?:
1 -> 2 -> 3
2 -> 1 -> 3
3 -> 2 -> 1
2 -> 3 -> 1
Answer & Solution
No Solution for this Answer..! Report or Discus this Question
16.
Which of these statements are incorrect?
Equal to operator has least precedence
Brackets () have highest precedence
Division operator, /, has higher precedence than multiplication operator
Addition operator, +, and subtraction operator have equal precedence
Answer & Solution
No Solution for this Answer..! Report or Discus this Question