My Report

Java Programming Mock Test 6


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 method of HashSet class is used to add elements to its object?

Question 1 of 10

Question 2 of 10

2. Which of these method Map class is used to obtain an element in the map having specified key?

Question 2 of 10

Question 3 of 10

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

 
    import java.lang.reflect.*;
    class Additional_packages
    {	 
         public static void main(String args[])
         {
	     try
             {
	         Class c = Class.forName("java.awt.Dimension");
		 Method methods[] = c.getMethods();
		 for (int i = 0; i < methods.length; i++)
		     System.out.println(methods[i]);
	     }
	     catch (Exception e)
             {
             System.out.print("Exception");
             }
        }
    }

Question 3 of 10

Question 4 of 10

4. What is the difference between TreeSet and SortedSet?

Question 4 of 10

Question 5 of 10

5. Which of this interface is not a part of Java's collection framework?

Question 5 of 10

Question 6 of 10

6. Which of these class object uses the key to store value?

Question 6 of 10

Question 7 of 10

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

 
    import java.util.*;
    class Bitset
    {
        public static void main(String args[])
        {
            BitSet obj1 = new BitSet(5);
            BitSet obj2 = new BitSet(10);
            for (int i = 0; i < 5; ++i)
                obj1.set(i);
            for (int i = 3; i < 13; ++i)
                obj2.set(i);
            obj1.and(obj2);
            System.out.print(obj1);
        }
    }

Question 7 of 10

Question 8 of 10

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

 
    import java.util.*;
    class Array 
    {
        public static void main(String args[]) 
        {
            int array[] = new int [5];
            for (int i = 5; i > 0; i--)
                array[5-i] = i;
            Arrays.fill(array, 1, 4, 8);
            for (int i = 0; i < 5 ; i++)
                System.out.print(array[i]);
        }
    }

Question 8 of 10

Question 9 of 10

9. Which of these methods is used to retrieve elements in BitSet object at specific location?

Question 9 of 10

Question 10 of 10

10. What is the worst case complexity of accessing an element in ArrayList?

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.