Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

100 Core Java Interview Questions and Answers - Part 8

Here are top selected core Java interview questions asked in high level interviews, these questions may be helpful for both freshers or experienced professional going for interview.



12345678910

71) What are immutable objects in Java?

In java, immutable objects are the objects which can not be changed once created. Any change to the states of these object results in a new object. String objects are the example of immutable objects in java any change to the states of an String object results in a new object and the old object remains unchanged.

72) What is the difference between a StringBuffer and StringBuilder class in Java?

In java both StringBuffer and StringBuilder classes are non immutable in nature, the only difference in between them is that StringBuffer class in thread-safe while StringBuilder is not thread safe in nature. StringBuilder class was introduced in Java5 to reduce the overhead of synchronization.

73) How many types of memory areas are allocated by JVM?

JVM allocated memory areas in many forms like:
1. Class(Method) Area
2. Heap
3. Stack
4. Program Counter Register
5. Native Method Stack

74) What if I changed the order of public static and void in ‘public static void main(String args[])’?

The program will compile fine and run properly, main() method implementation is regardless of the order of public, static and void keywords.

75) What is the default value for an instance variable in Java?

All instance variables are initialized to “null” by default.

76) What do you mean by composition in Java ?

Holding the reference of one class in another class in known as composition in Java.

77) Can be define an abstract method in an non abstract class ?

No, if a single method is declared as abstract in a class then the class must be declared as abstract itself.

78) Can we declare a class as abstract and final in Java?

No, we cannot declare an abstract method as final, abstract methods does not have body and they are meant to be overridden in another class, if we declare them final than its impossible to override them and hence no use of them.

12345678910










Thanks for reading !
Being Java Guys Team


RELATED POSTS

Java collection framework - Set, List and Map Interfaces in Java


ArrayList Implementation in Java - Java Collection Framework


HashMap Implementation in Java - Java Collection Framework


HashSet Implementation in Java - Java Collection Framework


Serialization and Deserialization in Java - Example





This post first appeared on Java, Struts 2, Spring, Hibernate, Solr, Mahout An, please read the originial post: here

Share the post

100 Core Java Interview Questions and Answers - Part 8

×

Subscribe to Java, Struts 2, Spring, Hibernate, Solr, Mahout An

Get updates delivered right to your inbox!

Thank you for your subscription

×