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. Which of the following method of Process class can terminate a process?

Question 1 of 50 (sanfoundry.com)

2. Which method can be used to check fileAccessiblity?

Question 2 of 50 (sanfoundry.com)

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

 
    class A
   {
       public int i;
       public int j;
       A()
       {
           i = 1;
           j = 2;
	}
   }   
   class B extends A
   {
       int a;
       B()
       {
           super();
       }
   }   
   class super_use
   {
       public static void main(String args[])
       {
           B obj = new B();
           System.out.println(obj.i + " " + obj.j);  
       }
  }

Question 3 of 50 (sanfoundry.com)

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

 
    import java.net.*;
    class networking 
    {
        public static void main(String[] args) throws UnknownHostException 
        {
            InetAddress obj1 = InetAddress.getByName("cisco.com");
            System.out.print(obj1.getHostName());
        }
    }

Question 4 of 50 (sanfoundry.com)

5. Which of these methods is used to compare a specific region inside a string with another specific region in another string?

Question 5 of 50 (sanfoundry.com)

6. Which of these exceptions handles the divide by zero error?

Question 6 of 50 (sanfoundry.com)

7. Which of these data type cannot be type parameterized?

Question 7 of 50 (sanfoundry.com)

8. Which of the following is not a JDBC connection isolation levels?

Question 8 of 50 (sanfoundry.com)

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

 
    class A 
    {
        int i;
        public void display() 
        {
            System.out.println(i);
        }    
    }    
    class B extends A 
   {
        int j;
        public void display() 
        {
            System.out.println(j);
        } 
    }    
    class Dynamic_dispatch 
   {
        public static void main(String args[])
        {
            B obj2 = new B();
            obj2.i = 1;
            obj2.j = 2;
            A r;
            r = obj2;
            r.display();     
        }
   }

Question 9 of 50 (sanfoundry.com)

10. What is an event in delegation event model used by Java programming language?

Question 10 of 50 (sanfoundry.com)

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

 
    import java.util.*;
    class stack 
    {
        public static void main(String args[]) 
        {
            Stack obj = new Stack();
            obj.push(new Integer(3));
            obj.push(new Integer(2));
            obj.pop();
            obj.push(new Integer(5));
     	    System.out.println(obj);
        }
    }

Question 11 of 50 (sanfoundry.com)

12. Which of these class contains the methods used to write in a file?

Question 12 of 50 (sanfoundry.com)

13. Which of these package is used for graphical user interface?

Question 13 of 50 (sanfoundry.com)

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

    class string_demo 
    {
        public static void main(String args[])
        {
            String obj = "I" + "like" + "Java";   
            System.out.println(obj);     
        }
   }

Question 14 of 50 (sanfoundry.com)

15. Which of these methods can be used to writing console output?

Question 15 of 50 (sanfoundry.com)

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

    class rightshift_operator 
    {
        public static void main(String args[]) 
        {    
             int x; 
             x = 10;
             x = x >> 1;
             System.out.println(x);
        } 
    }

Question 16 of 50 (sanfoundry.com)

17. Which of these is used to perform all input & output operations in Java?

Question 17 of 50 (sanfoundry.com)

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

 
    class newthread implements Runnable
    {
	Thread t;
	newthread()
        {
	    t = new Thread(this,"My Thread");
	    t.start();
	}
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            new newthread();        
        }
    }

Question 18 of 50 (sanfoundry.com)

19. What should be expression1 evaluate to in using ternary operator as in this line?

 expression1 ?  expression2  :  expression3 

Question 19 of 50 (sanfoundry.com)

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

Question 20 of 50 (sanfoundry.com)

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

 
    import java.util.*;
    class Linkedlist 
    {
        public static void main(String args[]) 
        {
            LinkedList obj = new LinkedList();
            obj.add("A");
            obj.add("B");
            obj.add("C");
            obj.removeFirst();
            System.out.println(obj);
        }
    }

Question 21 of 50 (sanfoundry.com)

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

    class Output 
    {
        public static void main(String args[]) 
        {    
             boolean a = true;
             boolean b = false;
             boolean c = a ^ b;
             System.out.println(!c);
        } 
    }

Question 22 of 50 (sanfoundry.com)

23. What exception thrown by parseInt() method?

Question 23 of 50 (sanfoundry.com)

24. Which of the following is not introduced with Java 8?

Question 24 of 50 (sanfoundry.com)

25. How can we take input text from user in HTML page?

Question 25 of 50 (sanfoundry.com)

26. Which of these methods is used to get x coordinate of the mouse?

Question 26 of 50 (sanfoundry.com)

27. How to specify autowiring by name?

Question 27 of 50 (sanfoundry.com)

28. Which of these Exceptions is thrown by remote method?

Question 28 of 50 (sanfoundry.com)

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

    class main_class 
    {
        public static void main(String args[])
        {
            int x = 9;
            if (x == 9) 
            { 
                int x = 8;
                System.out.println(x);
            }
        } 
    }

Question 29 of 50 (sanfoundry.com)

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

Question 30 of 50 (sanfoundry.com)

31. Which of these is a super class of wrappers Double and Float?

Question 31 of 50 (sanfoundry.com)

32. 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 32 of 50 (sanfoundry.com)

33. What is true about threading?

Question 33 of 50 (sanfoundry.com)

34. Which of these methods returns the class of an object?

Question 34 of 50 (sanfoundry.com)

35. What is true about do statement?

Question 35 of 50 (sanfoundry.com)

36. 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 36 of 50 (sanfoundry.com)

37. Which file separator should be used by MANIFEST file?

Question 37 of 50 (sanfoundry.com)

38. Which of this keyword must be used to inherit a class?

Question 38 of 50 (sanfoundry.com)

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

 class Alligator 
 {
  public static void main(String[] args) 
   {
   int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};
   int [][]y = x;
   System.out.println(y[2][1]);
   }
 }

Question 39 of 50 (sanfoundry.com)

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

 
    enum Season 
    {
        WINTER, SPRING, SUMMER, FALL
    };
    System.out.println(Season.WINTER.ordinal());

Question 40 of 50 (sanfoundry.com)

41. Which of these method of Object class can generate duplicate copy of the object on which it is called?

Question 41 of 50 (sanfoundry.com)

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

    class Output 
    {
        public static void main(String args[]) 
        {    
             int a = 5;
             int b = 10;
             first: 
             {
                second: 
                {
                   third: 
                   { 
                       if (a ==  b >> 1)
                           break second;
                   }
                   System.out.println(a);
                }
                System.out.println(b);
             }
        } 
    }

Question 42 of 50 (sanfoundry.com)

43. Which of this method of class StringBuffer is used to get the length of the sequence of characters?

Question 43 of 50 (sanfoundry.com)

44. Which of these class is not a member class of java.io package?

Question 44 of 50 (sanfoundry.com)

45. What is the relation between hashset and hashmap?

Question 45 of 50 (sanfoundry.com)

46. How does applet and servlet communicate?

Question 46 of 50 (sanfoundry.com)

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

    class access
    {
        public int x;
 	static int y;
        void cal(int a, int b)
        {
            x +=  a ;
            y +=  b;
        }        
    }    
    class static_specifier 
    {
        public static void main(String args[])
        {
            access obj1 = new access();
            access obj2 = new access();   
            obj1.x = 0;
            obj1.y = 0;
            obj1.cal(1, 2);
            obj2.x = 0;
            obj2.cal(2, 3);
            System.out.println(obj1.x + " " + obj2.y);     
        }
   }

Question 47 of 50 (sanfoundry.com)

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

import java.util.*;
public class Demo
{
    public static void main(String[] args)
    {
        Map<Integer, Object> sampleMap = new TreeMap<Integer, Object>();
        sampleMap.put(1, null);
        sampleMap.put(5, null);
        sampleMap.put(3, null);
        sampleMap.put(2, null);
        sampleMap.put(4, null);
 
        System.out.println(sampleMap);
    }
}

Question 48 of 50 (sanfoundry.com)

49. Which of these operators is used to allocate memory to array variable in Java?

Question 49 of 50 (sanfoundry.com)

50. How to read a classpath file?

Question 50 of 50 (sanfoundry.com)


 

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
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.