Instruction

  • This test contains a total of 15 questions.
  • Do not switch the tab or open a new window, otherwise, the test will be submitted automatically.
  • Test time is 10 minutes.

Java Beginner (Level 2)

Q 1.
What is the range of byte data type in Java?

Q 2.
Which of the following are legal lines of Java code?
1. int w = (int)888.8;
2. byte x = (byte)100L; 
3. long y = (byte)100; 
4. byte z = (byte)100L;

Q 3.
Which of these literals can be contained in float data type variable?

Q 4.
What will be the output of the following Java code?
class average {
    public static void main(String args[]) {
        double num[] = {
            5.5,
            10.1,
            11,
            12.8,
            56.9,
            2.5
        };
        double result;
        result = 0;
        for (int i = 0; i < 6; ++i) result = result + num[i];
        System.out.print(result / 6);
    }
}

Q 5.
What will be the output of the following Java code?
class increment {
    public static void main(String args[]) {
        int g = 3;
        System.out.print(++g * 8);
    }
}

Q 6.
Which of these coding types is used for data type characters in Java?

Q 7.
 Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?

Q 8.
What will be the output of the following Java program?
 class array_output 
    {
        public static void main(String args[]) 
        {
            char array_variable[] = new char[10];
            for (int i = 0; i < 10; ++i)
            { 
                array_variable[i] = 'i';
                System.out.print(array_variable[i] + "");
                i++; 
            }
        } 
    }

Q 9.
What will be the output of the following Java program?
class mainclass 
    { 
        public static void main(String args[])
        {
            boolean var1 = true;
            boolean var2 = false;
            if (var1) 
                System.out.println(var1);
            else 
                System.out.println(var2);
        }
    }

Q 10.
What will be the output of the following Java code?
class asciicodes {
    public static void main(String args[]) {
        char var1 = 'A';
        char var2 = 'a';
        System.out.println((int) var1 + " " + (int) var2);
    }
}

Q 11.
Which component is used to compile, debug and execute java program?

Q 12.
 Which component is responsible to run java program?

Q 13.
Which statement is true about java?

Q 14.
What is the extension of java code files?

Q 15.
How can we identify whether a compilation unit is class or interface from a .class file?


Time: