My Report

Java Programming Mock Test 1


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

Question 1 of 10

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

Question 1 of 10

Question 2 of 10

2. What is the range of short data type in Java?

Question 2 of 10

Question 3 of 10

3. How to copy contents of array?

Question 3 of 10

Question 4 of 10

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

    class leftshift_operator 
    {
        public static void main(String args[]) 
        {        
             byte x = 64;
             int i;
             byte y; 
             i = x << 2;
             y = (byte) (x << 2)
             System.out.print(i + " " + y);
        } 
    }

Question 4 of 10

Question 5 of 10

5. How to sort an array?

Question 5 of 10

Question 6 of 10

6. Which of these is an incorrect string literal?

Question 6 of 10

Question 7 of 10

7. If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?

Question 7 of 10

Question 8 of 10

8. Which operator is used to invert all the digits in a binary representation of a number?

Question 8 of 10

Question 9 of 10

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

 
    class multidimention_array 
    {
        public static void main(String args[])
        {
            int arr[][] = new int[3][];
            arr[0] = new int[1];
            arr[1] = new int[2];
            arr[2] = new int[3];               
	    int sum = 0;
	    for (int i = 0; i < 3; ++i) 
	        for (int j = 0; j < i + 1; ++j)
                    arr[i][j] = j + 1;
	    for (int i = 0; i < 3; ++i) 
	        for (int j = 0; j < i + 1; ++j)
                    sum + = arr[i][j];
	    System.out.print(sum); 	
        } 
    }

Question 9 of 10

Question 10 of 10

10. With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?

   1. x++;
   2. x = x + 1;
   3. x += 1;
   4. x =+ 1;

Question 10 of 10


 

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.