Mcq - Operators And Assignments In Java

21. What is the output of relational operators?

A. Integer
B. Boolean
C. Characters
D. Double

View Answer


22. Which of these is returned by “greater than”, “less than” and “equal to” operators?

A. Integers
B. Floating – point numbers
C. Boolean
D. None of the mentioned

View Answer


23. Which of the following operators can operate on a boolean variable?

1. &&
2. ==
3. ?:
4. +=

A. 3 & 2
B. 1 & 4
C. 1, 2 & 4
D. 1, 2 & 3

View Answer


24. Which of these operators can skip evaluating right hand operand?

A. !
B. |
C. &
D. &&

View Answer


25. Which of these statements is correct?

A. true and false are numeric values 1 and 0
B. true and false are numeric values 0 and 1
C. true is any non zero value and false is 0
D. true and false are non numeric values

View Answer


26. 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);
}
}

A. 1
B. 0
C. true
D. false

View Answer


27. What is the output of this program?

class ternary_operator
{
public static void main(String args[])
{
int x = 3;
int y = ~ x;
int z;
z = x > y ? x : y;
System.out.print(z);
}
}

A. 0
B. 1
C. 3
D. -4

View Answer


28. What is the output of this program?

class Output
{
public static void main(String args[])
{
int x , y = 1;
x = 10;
if (x != 10 && x / 0 == 0)
System.out.println(y);
else
System.out.println(++y);
}
}

A. 1
B. 2
C. Runtime error owing to division by zero in if condition
D. Unpredictable behavior of program

View Answer


29. What is the output of this program?

class Output
{
public static void main(String args[])
{
boolean a = true;
boolean b = false;
boolean c = a ^ b;
System.out.println(!c);
}
}

A. 0
B. 1
C. false
D. true

View Answer


30. Which of these have highest precedence?

A. ()
B ++
C. *
D. >>

View Answer







Also check :


Discussion


* You must be logged in to add comment.