Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

JAVA QUESTIONS : PART 10

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

SHOW ANSWER

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

SHOW ANSWER

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

SHOW ANSWER

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

SHOW ANSWER

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

compile time error

20

run time error

compile and runs fine

SHOW ANSWER

Which of these selection statements test only for equality?

if

switch

if & switch

 none of the mentioned

SHOW ANSWER

Which of these are selection statements in Java?

if()

for()

 continue

break

SHOW ANSWER

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

do-while

while

for

none of the mentioned

SHOW ANSWER

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

1

2

3

 4

SHOW ANSWER

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

SHOW ANSWER

What is true about a break?

Break stops the execution of entire program

Break halts the execution and forces the control out of the loop

Break forces the control out of the loop and starts the execution of next iteration

 Break halts the execution of the loop for certain time frame

SHOW ANSWER

What is true about do statement?

do statement executes the code of a loop at least once

do statement does not get execute if condition is not matched in the first iteration

do statement checks the condition at the beginning of the loop

do statement executes the code more than once always

SHOW ANSWER

Which of the following is used with the switch statement?

Continue

Exit

break

 do

SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in