AmbitionBox

Discover Best Places to work in India

Java Programming

Java Programming Questions and Answers

Showing 21 - 30 of 37 questions

21

The signed right shift operator in Java is --. Select the one correct answer.

a

<<

b

>>>

c

>>

d

None of these

correct answer c
22
intx = 0, y = 0 , z = 0 ;
x = (++x + y-- ) * z++;

What will be the value of "x" after execution ?

a

-2

b

-1

c

0

d

1

correct answer c

C is the correct answer.

23
int ++a = 100 ; 
System.out.println( ++a ) ;

What will be the output of the above fraction of code ?

a

b

 

c

Compiler displays error as ++a is not a valid identifier

d

None of these

correct answer c

C is the correct answer.

24
What is the output of the following program ?
class Numbers{public static void main(String args[]){inta=20, b=10;
                if((a < b) && (b++ < 25)){
                        System.out.println("This is any language logic");
                }
                System.out.println(b); 
        }
}
a

12

b

11

 

c

10

d

None of these

correct answer c

C is the correct answer.

25

Select from among the following character escape code which is not available in Java.

a

\t

b

\r

 

c

\a

d

None of these

correct answer c

C is the correct answer.

26

What will be the output?

if(1 + 1 + 1 + 1 + 1 == 5){
        System.out.print("TRUE");
}else{
        System.out.print("FLASE");
}
a

True

b

False

 

c

Compiler Error

d

None of these

correct answer a

A is the correct answer.

27

Consider the following code fragment:

int x;

int a = 5;

int b= 8;

x = ++a + b++;

After the execution of this code fragment, what is the value of x?

a

A. 13

b

B. 14

c

C. 15

d

D. Compilation fails

correct answer b
28

Consider the following code fragment:

1. public class Unary{

2. public static void main(String[] args) {

3. byte x = 7;

4. byte y = 6*x++;

5. byte z = x*y;

6. System.out.println ("z: " + z);

7. }

What is the output of this code fragment?

a

A. z:42

b

B. z:48

c

C. The code will not compile due to line 4.

d

D. The code will compile but will generate a run time error.

correct answer c
29

Consider the following code fragment:

public class Unary

{

public static void main(String[] args)

{

int x = 7;

int y = 6*x++;

System.out.println (" y= " + y);

int a = 7;

int b = 6*++a;

System.out.println (" b= " + b);

}

}

What is the output of this code fragment?

a

A. y=42

     b=48

b

B. y=48

     b=48

c

C. y=48

     b=42

d

D. y=42

     b=42

correct answer
30

Consider the following code fragment:

int x = 9;

int y = -2;

System.out.println("output: " + x%y);

What is the output of this code fragment?

a

A. -1

b

B. 1

c

C. 4.5

d

D. 4

correct answer b
Select a company to compare with

vs

Similar Companies