My Report

Java Programming Practice 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

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

 
    import java.util.*;
    class vector 
    {
        public static void main(String args[]) 
        {
            Vector obj = new Vector(4,2);
            obj.addElement(new Integer(3));
            obj.addElement(new Integer(2));
            obj.addElement(new Integer(5));
            obj.removeAll(obj);
            System.out.println(obj.isEmpty());
        }
    }

2. Which of these class is used for creating a client for a server-client operations?

3. Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes?

4. Which of these method is used to make a bit zero specified by the index?

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

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

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

7. Which of these return type of hasNext() method of an iterator?

8. Which of these methods deletes all the elements from invoking collection?

9. What is difference between dequeue() and peek() function of java?

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

 
    import java.util.*;
    class Collection_iterators 
    {
        public static void main(String args[]) 
        {
            ListIterator a = list.listIterator();
                if(a.previousIndex()! = -1)
                    while(a.hasNext())
	                System.out.print(a.next() + " ");
                else
                   System.out.print("EMPTY");
        }
    }

 

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.