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 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

SHOW ANSWER

Which of these have highest precedence?

( )

 ++

*

>>

SHOW ANSWER

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 and runs fine

20

run time error

compile time error

SHOW ANSWER

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

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 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

SHOW ANSWER

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

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
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in