Java - MCQ

Multiple Choice Questions


Share with a Friend

 

Java MCQ - Introduction to Java - Set 17

81. What will be the output of the program?

class Test 
{
    public static void main(String [] args) 
    {
        int x=20;
        String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";
        System.out.println(sup);
    }
}
A). small
B). tiny
C). huge
D). Compilation fails
View Answer
Correct: B



82. What will be the output of the program?

class Test 
{
    public static void main(String [] args) 
    {
        int x= 0;
        int y= 0;
        for (int z = 0; z < 5; z++) 
        {
            if (( ++x > 2 ) || (++y > 2)) 
            {
                x++;
            }
        }
    System.out.println(x + " " + y);
    }
}
A). 5 3
B). 8 2
C). 8 3
D). 8 5
View Answer
Correct: B



83. What will be the output of the program?

class Bitwise 
{
    public static void main(String [] args) 
    {
        int x = 11 & 9;
        int y = x ^ 3;
        System.out.println( y | 12 );
    }
}
A). 0
B). 7
C). 8
D). 14
View Answer
Correct: D



84. Size of float and double in Java is
A). 32 and 64
B). 64 and 64
C). 32 and 32
D). 64 and 32
View Answer
Correct: A



85. What would be the output of the following fraction of code ?

int Integer = 34 ;
char String = 'S' ;
System.out.print( Integer ) ;
System.out.print( String ) ;
A). Does not compile as Integer and String are API class names.
B). S
C). 34
D). 34 S
View Answer
Correct: D



 
 
 
   
   
   
UltraInfo Technologies
ITDeveloper