My Report

Java Basic Online Test – 2


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of these values can a boolean variable contain?

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

3. 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);
       } 
    }

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

5. What will be the output of the following Java code?

    class booloperators {
        public static void main(String args[]) 
        {
            boolean var1 = true;
	    boolean var2 = false;
	    System.out.println((var1 & var2));
        } 
    }

6. 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++;
            }
        } 
    }

7. 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);
        } 
    }

8. What is the numerical range of a char data type in Java?

9. Which one is a valid declaration of a boolean?

10. What will be the output of the following Java program?

    class mainclass {
        public static void main(String args[]) 
        {
            char a = 'A';
            a++;
	    System.out.print((int)a);
        } 
    }

 

Start practicing “1000 MCQs on Java”, and once you are ready, you can take tests on all topics by attempting our “Java Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.