My Report

Java Programming Mock Test 5


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 process occur automatically by java run time system?

Question 1 of 10

Question 2 of 10

2. Which of these class is used to encapsulate IP address and DNS?

Question 2 of 10

Question 3 of 10

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

 
    import java.io.*;
    class streams
    {
        public static void main(String[] args) 
        {
            try
            {
	        FileOutputStream fos = new FileOutputStream("serial");
	        ObjectOutputStream oos = new ObjectOutputStream(fos);
                oos.writeFloat(3.5);
                oos.flush();
                oos.close();
	    }
	    catch(Exception e)
            {
	        System.out.println("Serialization" + e);
                System.exit(0);
            }
	    try 
            {
	        float x;
	        FileInputStream fis = new FileInputStream("serial");
	        ObjectInputStream ois = new ObjectInputStream(fis);
                x = ois.readInt();
                ois.close();
	        System.out.println(x);		    	
	    }
	    catch (Exception e)
            {
                System.out.print("deserialization");
	        System.exit(0);
	    }
        }
    }

Question 3 of 10

Question 4 of 10

4. Which of these method is used to start a server thread?

Question 4 of 10

Question 5 of 10

5. Which of these methods return string equivalent of Boolean object?

Question 5 of 10

Question 6 of 10

6. Which of these class is used to create servers that listen for either local or remote client programs?

Question 6 of 10

Question 7 of 10

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

 
    import java.io.*;
    class streams
    {
        public static void main(String[] args)
        {
            try
            {
	        FileOutputStream fos = new FileOutputStream("serial");
	        ObjectOutputStream oos = new ObjectOutputStream(fos);
	        oos.writeFloat(3.5);
	        oos.flush();
	        oos.close();
	    }
	    catch(Exception e)
            {
	        System.out.println("Serialization" + e);
                System.exit(0);
            }
	    try
            {
	        FileInputStream fis = new FileInputStream("serial");
	        ObjectInputStream ois = new ObjectInputStream(fis);
	        ois.close();
	        System.out.println(ois.available());		    	
	    }
	    catch (Exception e)
            {
                System.out.print("deserialization");
	        System.exit(0);
	    }
        }
    }

Question 7 of 10

Question 8 of 10

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

 
    class X
    {
        int a;
        double b;
    }
    class Y extends X 
    {
	int c;
    }
    class Output 
    {
        public static void main(String args[]) 
        {
            X a = new X();
            Y b = new Y();
            Class obj;
            obj = b.getClass();
            System.out.print(obj.getSuperclass());
        }
    }

Question 8 of 10

Question 9 of 10

9. 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 9 of 10

Question 10 of 10

10. Which of these method returns a smallest whole number greater than or equal to variable X?

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.