

Home Interviewquestions Corejava Core Java Interview Question, Interview Question


Share on Google+Share on Google+

Core Java Interview Question, Interview Question

This page discusses - Core Java Interview Question, Interview Question

Core Java Interview Question Page 32


java.lang & java.util Packages

Question: What is the ultimate ancestor of all java classes

Answer: Object class is the ancestor of all the java classes

Question: What are important methods of Object class

Answer: wait(), notify(), notifyAll(), equals(), toString().

Question: What is the difference between ?= =? and ?equals()?

Answer: ?= =? does shallow comparison, It retuns true if the two object points to the same address in the memory, i.e if the same the same reference
?equals()? does deep comparison, it checks if the values of the data in the object are same



Question: Give example of a final class

Answer: Math class is final class and hence cannot be extended

Question: What is the difference between String and StringBuffer

Answer: String is an immutable class, i.e you cannot change the values of that class


String str = ?java?; // address in memory say 12345
And now if you assign a new value to the variable str then
str = ?core java?; then the value of the variable at address 12345 will not change but a new memory is allocated for this variable say 54321
So in the memory address 12345 will have value ?java?
And the memory address 54321 will have value ?core java? and the variable str will now be pointing to address 54321 in memory

StringBuffer can be modified dynamically
StringBuffer strt =?java? // address in memory is say 12345
Str = ?core java?; then value in the address of memory will get replaced, a new memory address is not allocated in this case.

Question: What will be the result if you compare StringBuffer with String if both have same values

Answer: It will return false as you cannot compare String with StringBuffer

Question: What is Collection API

Answer: The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces.
Example of classes: HashSet, HashMap, ArrayList, LinkedList, TreeSet and TreeMap.
Example of interfaces: Collection, Set, List and Map.

Question: What are different types of collections

Answer: A collection has no special order and does not reject duplicates
A list is ordered and does not reject duplicates
A set has no special order but rejects duplicates
A map supports searching on a key field, values of which must be unique

Question: Tell me something about Arrays

Answer: Arrays are fast to access, but are inefficient if the number of elements grow and if you have to insert or delete an element

Question: Difference between ArrayList and Vector

Answer: Vector methods are synchronized while ArrayList methods are not

Question: Iterator a Class or Interface? What is its use?

Answer: Iterator is an interface which is used to step through the elements of a Collection

Question: Difference between Hashtable and HashMap

Answer: Hashtable does not store null value, while HashMap does
Hashtable is synchronized, while HashMap is not



Liked it!  Share this Tutorial


Posted on: April 18, 2011

Related Tutorials

Discuss: Core Java Interview Question, Interview Question  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
jujhar singh
June 13, 2011
core java interview questions

helo, please do send me some more questions regarding the core java if i have to undergo an interview as a software developer