My Report

Java Programming Mock Test 8


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. Which of these values is returned by read() method is end of file (EOF) is encountered?

Question 1 of 10

Question 2 of 10

2. Which of these methods is used to obtain the object that generated a WindowEvent?

Question 2 of 10

Question 3 of 10

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

 
    import java.io.*;
    class Chararrayinput
    {
        public static void main(String[] args)
        {
	    String obj  = "abcdefgh";
            int length = obj.length();
            char c[] = new char[length];
            obj.getChars(0, length, c, 0);
            CharArrayReader input1 = new CharArrayReader(c);
            CharArrayReader input2 = new CharArrayReader(c, 1, 4);
            int i;
            int j;
            try 
            {
		while((i = input1.read()) == (j = input2.read()))
                {
                    System.out.print((char)i);
                }
       	    } 
            catch (IOException e)
            {
                e.printStackTrace();
	    }
	}
    }

Question 3 of 10

Question 4 of 10

4. Which of these methods can be used to get reference to a component that was removed from a container?

Question 4 of 10

Question 5 of 10

5. Which of these methods is used to notify observer the change in observed object?

Question 5 of 10

Question 6 of 10

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

   
    class output
    {
        public static void main(String args[])
        { 
             StringBuffer c = new StringBuffer("Hello");
             StringBuffer c1 = new StringBuffer(" World");
             c.append(c1);
             System.out.println(c);
        }
    }

Question 6 of 10

Question 7 of 10

7. What will be the output of the following Java program if input given is 'abcqfghqbcd'?

 
    class Input_Output
    {
        public static void main(String args[]) throws IOException
        {	 
            char c;
            BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));
            do
            {
                c = (char) obj.read();
	        System.out.print(c);
            } while(c != 'q');
        }
    }

Question 7 of 10

Question 8 of 10

8. What is the range of numbers returned by Math.random() method?

Question 8 of 10

Question 9 of 10

9. Which of these is a type of stream in Java?

Question 9 of 10

Question 10 of 10

10. Which of these methods are used to register a keyboard event listener?

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.