Language Fundamentals

Q1: What will be the output of the program ?
public class Test 
{
    public static void main(String [] args) 
    {
        signed int x = 10;
        for (int y=0; y<5; y++, x--)
            System.out.print(x + ', ');
    }
}

A 10, 9, 8, 7, 6,

B 9, 8, 7, 6, 5,

C Compilation fails.

D An exception is thrown at runtime.

ANS:A - 10, 9, 8, 7, 6,

The word 'signed' is not a valid modifier keyword in the Java language. All number primitives in Java are signed. Hence the Compilation will fails.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.