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. Which of these is a return type of getAddress() method of DatagramPacket class?

2. When two threads access the same ArrayList object what is the outcome of the program?

3. Which of these methods are member of Remote class?

4. 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));
            System.out.println(obj.capacity());
        }
    }

5. Which of these method is used to remove all keys/values pair from the invoking map?

6. How to sort elements of ArrayList?

7. Is hashmap an ordered collection.

8. Which of the below is not a subinterface of Queue?

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

 
    import java.util.*;
    class date
    {
        public static void main(String args[])
        {
            Date obj = new Date();
            System.out.print(obj);
        }
    }

10. 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.length() + " " + obj.size());
        }
    }

 

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.