9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855 SEARCHING FOR ACADEMIC PROJECT?
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855    ### JAVA QUESTIONS : PART 29

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

1

2

Runtime error owing to division by zero in if condition

Unpredictable behavior of program

Which of these have highest precedence?

( )

++

*

>>

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

0

1

9

8

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

What is the output of this program?
class Operators
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
int var3;
var3 = ++ var2 * var1 / var2 + var2;
System.out.print(var3);
}
}

10

11

12

56

What is the output of this program?
class Operators
{
public static void main(String args[])
{
int x = 8;
System.out.println(++x * 3 + " " + x);
}
}

24 8

24 9

27 8

27 9

What is the output of this program?
class Output
{
public static void main(String args[])
{
int x=y=z=20;
}
}

compile and runs fine

20

run time error

compile time error

What is the output of this program?
class Sample
{
public static void main(String args[])
{
int a,b,c,d;
a=b=c=d=20
a+=b-=c*=d/=20
System.out.println(a+" "+b+" "+c+" "+d);
}
}

compile time error

runtime error

a=20 b=0 c=20 d=1

none of the mentioned

Which of these selection statements test only for equality?

if

switch

if & switch

none of the mentioned

Which of these are selection statements in Java?

if()

for()

continue

break

Which of this statement is incorrect?

switch statement is more efficient than a set of nested ifs

two case constants in the same switch can have identical values

switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression

it is possible to create a nested switch statements

What is the output of this program?
class Sample
{
public static void main(String args[])
{
int var1 = 5;
int var2 = 6;
if ((var2 = 1) == var1)
System.out.print(var2);
else
System.out.print(++var2);
}
}

1

2

3

4

What would be the output of the following codesnippet if variable a=10?
if(a<=0)
{
if(a==0)
{
System.out.println("1 ");
}
else
{
System.out.println("2 ");
}
}
System.out.println("3 ");

1 2

2 3

1 3

3