My Report (&Account)

Java Online Test


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

Here is the complete list of test quizzes on Java.

1. groupCount reports a total number of Capturing groups.

Question 1 of 50

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

   
    class Output 
    {
         public static void main(String args[]) 
         {
             double x = 3.14;  
             int y = (int) Math.abs(x);
             System.out.print(y);
         }
    }

Question 2 of 50

3. What temporarily redirects response to the browser?

Question 3 of 50

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

 
    import java.io.*;
    class serialization 
    {
        public static void main(String[] args) 
        {
            try 
            {
                Myclass object1 = new Myclass("Hello", -7, 2.1e10);
	        FileOutputStream fos = new FileOutputStream("serial");
	        ObjectOutputStream oos = new ObjectOutputStream(fos);
                oos.writeObject(object1);
                oos.flush();
                oos.close();
	    }
	    catch(Exception e) 
            {
	        System.out.println("Serialization" + e);
                System.exit(0);
            }
	    try
            {
	        int 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);
	    }
        }
    }
    class Myclass implements Serializable
    {
	String s;
	int i;
	double d;
        Myclass(String s, int i, double d)
        {
	    this.d = d;
	    this.i = i;
	    this.s = s;
	}
    }

Question 4 of 50

5. what does public String replaceAll(string replace) do?

Question 5 of 50

6. How are java web applications packaged?

Question 6 of 50

7. What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY?

Question 7 of 50

8. What is use of interpreter?

Question 8 of 50

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

 
    class char_increment 
    {
        public static void main(String args[]) 
        {
            char c1 = 'D';
            char c2 = 84;
            c2++;
            c1++;
            System.out.println(c1 + " "  + c2);
        } 
    }

Question 9 of 50

10. Which of the following leads to high network traffic?

Question 10 of 50

11. Which of the following operators can operate on a boolean variable?

   
   1. &&
   2. ==
   3. ?:
   4. +=

Question 11 of 50

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

 
    class exception_handling 
    {
        public static void main(String args[]) 
        {
            try 
            {
                System.out.print("Hello" + " " + 1 / 0);
            }
            finally 
            {
        	System.out.print("World");        	
            }
        }
    }

Question 12 of 50

13. What is the relation between hashset and hashmap?

Question 13 of 50

14. Decrement operator, −−, decreases the value of variable by what number?

Question 14 of 50

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

Question 15 of 50

16. Which of these methods will respond when you click any button by mouse?

Question 16 of 50

17. Which of these methods of Boolean wrapper returns boolean equivalent of an object.

Question 17 of 50

18. How does applet and servlet communicate?

Question 18 of 50

19. Which of these methods return description of an exception?

Question 19 of 50

20. Which of these method of Object class can clone an object?

Question 20 of 50

21. Which component is responsible to optimize bytecode to machine code?

Question 21 of 50

22. How can a protected modifier be accessed?

Question 22 of 50

23. Which of the following method is used inside session only?

Question 23 of 50

24. Which of these methods is used to print stack trace?

Question 24 of 50

25. Which of these methods is used to know the type of content used in the URL?

Question 25 of 50

26. If the size of the array used to implement a circular queue is MAX_SIZE. How rear moves to traverse inorder to insert an element in the queue?

Question 26 of 50

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

 
    class Output 
    {
        public static void main(String args[]) 
        {
            char a[] = {'a', '5', 'A', ' '};   
            System.out.print(Character.isDigit(a[0]) + " ");
            System.out.print(Character.isWhitespace(a[3]) + " ");
            System.out.print(Character.isUpperCase(a[2]));
        }
    }

Question 27 of 50

28. Which of the following methods return the value as a double?

Question 28 of 50

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

 
    import java.util.*;
    class Bitset
    {
        public static void main(String args[])
        {
            BitSet obj = new BitSet(5);
            for (int i = 0; i < 5; ++i)
                obj.set(i);
            obj.clear(2);
            System.out.print(obj);
        }
    }

Question 29 of 50

30. Which of the following methods is not used while Serialization and DeSerialization?

Question 30 of 50

31. Standard output variable 'out' is defined in which class?

Question 31 of 50

32. What does assertSame() method use for assertion?

Question 32 of 50

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

    import java.util.*;
    class Output
    {
        public static double sumOfList(List<? extends Number> list)
        {
            double s = 0.0;
            for (Number n : list)
                s += n.doubleValue();
            return s;
        }
        public static void main(String args[])
        {
            List<Integer> li = Arrays.asList(1, 2, 3);
            System.out.println(sumOfList(li));
        }
    }

Question 33 of 50

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

public class Shape 
{
	public int area()
        {
		return 1;
	}
}
public class Square extends Shape 
{
	public int area()
        {
		return 2;
	}
}
class Main() 
{
   public static void main(String[] args)
   {
	Shape shape = new Shape();
	Square square = new Square();
	square = shape;
	System.out.println(square.area());
   }
}

Question 34 of 50

35. At runtime, error is recoverable.

Question 35 of 50

36. How many arguments can be passed to main()?

Question 36 of 50

37. What will be the output of the following Java code snippet?

enum Enums
{
    A, B, C;
     
    private Enums()
    {
        System.out.println(10);
    }
}
 
public class MainClass
{
    public static void main(String[] args)
    {
        Enum en = Enums.B;
    }
}

Question 37 of 50

38. Which of these class defines how the classes are loaded?

Question 38 of 50

39. Where is a new object allocated memory?

Question 39 of 50

40. Which of these access specifiers must be used for main() method?

Question 40 of 50

41. Which of this class can be used to format dates and times?

Question 41 of 50

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

    import java.util.*;
    public class genericstack <E>
    {
        Stack <E> stk = new Stack <E>();
	public void push(E obj)
        {
            stk.push(obj);
	}
	public E pop()
        {
            E obj = stk.pop();
	    return obj;
	}
    }
    class Output
    {
        public static void main(String args[])
        {
            genericstack <String> gs = new genericstack<String>();
            gs.push("Hello");
            System.out.print(gs.pop() + " ");
            genericstack <Integer> gs = new genericstack<Integer>();
            gs.push(36);
            System.out.println(gs.pop());
        }
    }

Question 42 of 50

43. AutoCloseable and Flushable are part of which package?

Question 43 of 50

44. Which of these class object has an architecture similar to that of array?

Question 44 of 50

45. What will be the output of the following Java code snippet running with "java demo I write java code"?

public class demo
{
   public static void main(String args[])
   {
        System.out.println(args[0]+""+args[args.length-1]);
   }
}

Question 45 of 50

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

    class box 
    {
        int width;
        int height;
        int length;
        int volume;
        void volume() 
        {
            volume = width * height * length;
        } 
        void volume(int x) 
        {
            volume = x;
        }
    }    
    class Output 
    { 
        public static void main(String args[]) 
        {
            box obj = new box();
            obj.height = 1;
            obj.length = 5;
            obj.width = 5;
            obj.volume(5);
            System.out.println(obj.volume);        
        } 
    }

Question 46 of 50

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

Question 47 of 50

48. Which of the below does not implement Map interface?

Question 48 of 50

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

 
    class output 
    {
        public static void main(String args[])
        { 
           StringBuffer s1 = new StringBuffer("Hello");
           StringBuffer s2 = s1.reverse();
           System.out.println(s2);
        }
    }

Question 49 of 50

50. Which of this method of class String is used to extract a substring from a String object?

Question 50 of 50


 

Topic wise Test Quizzes on Java

Java tests, quizzes, and exams are great ways to learn and test your Java programming skills. Whether you’re a beginner or experienced, challenge and boost your confidence with our engaging online quizzes on Java basics, oops, arrays, exceptions, constructors, collections, multithreading, JDBC, and advanced java. Start the Java online test now!



Java Programming Certification Test

Java Programming Certification Test is a free certification exam. However, you need to score an A grade in each of the "Certification Level Tests 1 to 10" to be eligible to take part in this certification test. So, take all the "10 Tests" starting from Certification Level 1 upto Level 10, before taking the final Certification test.


Level 1 to 10 Tests:
Total Questions: 25, Total Time: 30 min, Correct Answer: 2 points, Wrong Answer: -1 point

Certification Test:
Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

Java Programming Internship Test

If you scored either Grade A* or Grade A in our Java Programming Internship Test, then you can apply for Internship at Sanfoundry in Java Programming.


Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

Java Programming Job Test

It is designed to test and improve your skills for a successful career, as well as to apply for jobs.


Total Questions: 50, Total Time: 1 hour, Correct Answer: 2 points, Wrong Answer: -1 point

Note: Before you get started on these series of online tests, you should practice our collection of 1000 MCQs on Java Programming .

Sanfoundry Scoring & Grading System

Sanfoundry tests and quizzes are designed to provide a real-time online exam experience. Here is what you need to know about them.

  • Scoring System: You get 2 points for each correct answer but lose 1 point for every wrong answer.
  • Grading System: Your grade depends on your final score and can be one of the following:

    • Grade A* - Genius (100%)
    • Grade A - Excellent (80% to 99%)
    • Grade B - Good (60% to 80%)
    • Grade C - Average (40% to 60%)
    • Grade D - Poor (0% to 40%)
advertisement
advertisement
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.