Java Interview Questions and Answers

What is the Vector class?
The Vector class provides the capability to implement a growable array of objects.
What is an Iterator interface?
The Iterator interface is used to step through the elements of a Collection .
Which java.util classes and interfaces support event handling?
The EventObject class and the EventListener interface support event processing.
What is the GregorianCalendar class?
The GregorianCalendar provides support for traditional Western calendars
What is the Locale class?
The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region .
What is the SimpleTimeZone class?
The SimpleTimeZone class provides support for a Gregorian calendar .
What is the Map interface?
The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.
What is the highest-level event class of the event-delegation model?
The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.
What is the Collection interface?
The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.
What is the Set interface?
The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements. .
What is the difference between the size and capacity of a Vector?
The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time.
Can a vector contain heterogenous objects?
Yes a Vector can contain heterogenous objects. Because a Vector stores everything in terms of Object.
Can a ArrayList contain heterogenous objects?
Yes a ArrayList can contain heterogenous objects. Because a ArrayList stores everything in terms of Object.
What is an enumeration?
An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It is a construct which collection classes return when you request a collection of all the objects stored in the collection. It allows sequential access to all the elements stored in the collection. Considering the basic properties of Vector and ArrayList, where will you use Vector and where will you use ArrayList? The basic difference between a Vector and an ArrayList is that, vector is synchronized while ArrayList is not. Thus whenever there is a possibility of multiple threads accessing the same instance, one should use Vector. While if not multiple threads are going to access the same instance then use ArrayList. Non synchronized data structure will give better performance than the synchronized one.
Can a vector contain heterogenous objects?
Yes a Vector can contain heterogenous objects. Because a Vector stores everything in terms of Object.
Describe synchronization in respect to multi-threading?

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors. 

Latest Updates

Physics

Atmospheric pressure at sea level equals ?

General Knowledge of India

Which of the following dance forms was introduced by the great Vaishnava saint and reformer Mahapurusha Sankaradeva ?

Which of the following is the only classical dance of india having links with Muslim culture and represents a unique synthesis of Hindu and Muslim genius in art ?

Time and Distance

Starting from the same point at the same time, Ruhan and Yuvan had to reach the same destination. While Ruhan drove at 45 km/hr, Yuvan was slower by 5 km/hr. If Yuvan arrived at the destination an hour after Ruhan did, the distance covered by each, in Kilometres, was ?

Simple Interest

A sum of money was invested at a certain rate of simple interest for 4 years. Had the sum been invested at a rate 3% higher than the actual rate, the interest earned would have been 720 Rs more. Find the sum initially invested?

Ratio and Proportion

A bag contains red, blue and black balls. The ratio of red to blue balls is 3 : 5. The ratio of black to red balls is 3 : 4. What is the ratio of blue to black balls?

Profit and Loss

Selling a pack of incense sticks for 136 Rs resulted in a loss of 15%. To make a profit of 10%, the selling price should be ?

Percentage

23% of a bucket full of diluted milk was water. If the quantity of pure milk in the bucket was 15.4 liter, then the capacity of the bucket was ?

Average

The average of the marks obtained by three girls in a test was twice the average of the marks obtained by eight boys in that test. If the total marks obtained by all these examinees was 168, find the average marks each of the girls obtained ?

Pipes and Cistern

44 pipes can fill a large water tank in 27 hours. How many hours it take for 66 pipes to fill four such tanks ?

HCF and LCM

A natural number, when divided by 3, 4, 5, 6, and 7 respectively, leaves corresponding remainder of 2, 3, 4, 5 and 6. What is the smallest of all such numbers fulfilling the above condition ?

Coding-Decoding

If in a certain code language, PRINT is written as 34825 and TRUE is written as 5479. Then, how will TENURE be written in that language?

Order Sequence

Arrange the given words from smallest to biggest-
1.Jug
2.Mug
3.Bucket
4.Drum
5.Cup

Statement and Conclusion

Statements
All socks are shoes
Some shoes are black

Conclusions
I. Some shoes are socks.
II. No scoks is black

Numbers

The difference between the place value of 4 and 2 in the number 833749502 is ?

Analogy

GIKM : HJLN :: PRTV : .........?

Order Sequence

In a row of girls, Nanda is eighth from the left and Chanda is nineteenth from right. When Nanda and Chanda interchange their positions, Chanda becomes twnty-third form right. How many girls are there in the row?

Analogy

Summer: Day :: Winter : ........?