Sunday, 24 August 2014

Java / J2ee interview questions for experience java developer

Interview generally starts with:
                 *  Tell me about yourself.
                 * Tell me about your current project and your role in it. And few related questions on project, if he gets what you have explained.

       Then they start with core java. Be very much perfect in core java concepts, because this is the section which will decide your fate in interview. Even if you suck at j2ee part, and if you are very much good at core java concepts then consider you are almost in. Best book I suggest for core java preparation is SCJP (OCJP) by Kathy Sierra.  And following are few important questions for your quick review.

     Key point to remember:  Do not answer the question if you don’t know the answer. It’s better than answering it wrong.


Core Java interview questions for experienced developer:

  1.   Explain OOPS concepts with example.
  2.  What is difference between abstraction and encapsulation?
  3.  What is difference between abstract class and Interface?
  4.   What is polymorphism? Explain with example.
  5.   Can we override static method?
  6.  Can we overload the static method?
  7.  What is base class of java?And what methods it provides? Ans: It's Object and methods are : Clone(), equals(), hashCode(), finalize(), notify(), notifyAll(), wait(), toString()
  8. How variables are defined in interface and how to access it?
  9.  Explain System.out.println() in detail     
  10. What is final object in java? 
  11. What is static import in java?
  12. What is agreement between equals() and  hashcode() methods in java?
  13. What will print on console, if I don’t override toString() method and I pass object to  System.out.println()? Ans: If you don’t override toString() method & pass object to System.out.println(), then it will print classname followed by @ symbol, followed by unsigned hexadecimal representation of objects  hashcode. 

Now as you are 3+ years of experience, generally interviewers don’t ask you direct question. They might ask you to consider a scenario and asks questions in-between or expect you to correct him, if he is going wrong somewhere. Consider the following scenarios: 

Scenario 1:
I have two classes A & B. Where class B extends class A. And now I’m having one more Test class, to test it. Now I have created one reference of class B and provide it object of class A. Like, 
                  B obj = new A();   

Here, he expects you to correct him, that you cannot store object of parent class into reference of base class.

Scenario 2:
File name:
class A{
      String name = "Parent Class";
      public void printMe(){
            System.out.println("This is parent class");

class B extends A{
      String name = "Base Class";
      public void printMe(){
            System.out.println("This is base class");
public class Test {
      public static void main(String[] args) {
            A objA = new B();
            System.out.println("Name is :";


Now when I run this test class, what will be the output?

Name is :Parent Class
This is base class

Now few things to learn here:

      #   Java file may contain more than one class classes, but only one public class. And this public class name should be same as that of file name.
     #  Java provides method overriding but not variable overriding. That is why, when I print variable name, it will pick up the variable definition from the class of which reference is created i.e. A. And method of the class of which object is created i.e. B.


       Interview question on String class in Java:

  1. What is difference between String, StringBuffer and StingBuilder? In what scenarios they should be used?
  2. What is String.intern() method?
  3. What is mutable and immutable class? Where does String class belongs to? How to write immutable class
  4. What will be output for following:
String a = "abc";
            String b = "abc";
            String c = new String("abc");
            String d = new String("abc");

                  System.out.println("a equals b");
                  System.out.println("a equals c");
                  System.out.println("c equals d");

a equals b
a equals c
c equals d


Important point about String, you should know:

  1. String is final class, this means you cannot extend it or inherit it.
  2. String is immutable. This means, every time you assign value to it, it will be stored at new memory location.
  3. Whenever we assign value to String variable directly using double quote (without new keyword), it will check for that value in String pool and if it exists, it directly reference to that memory location without creating new one.
  4. And whenever we use new keyword, it creates new memory location to store that object.
  5. As we know == checks for memory location to compare, it will not return true for a==c & c==d  (.equals() method checks for value in object)


       Interview question on Serialization in Java: 

  1.  What is serialization? Why we use it? How did you use it? Short Ans : The primary purpose of serialization is to write an object into a stream, so that it can be transported through network and object can be rebuild from it on the other end. And other  purpose is to store state of object and retrieve it back. Or you can say to persist the object  across the sessions.
  2. I serialize the object which contains reference of non serialized object? Ans: No, it will throw nonSerializableException
  3. Explain steps of serialization
  4. What are transient variables?  Give real time example.  Ans:  Variables which you don't want to serialized are marked as transient. Example age in student object is kept transient, so as to it will be calculated on the basis of its birth date and current date comparison.
  5. Can we mark method as transient ? Ans: No 





  1. Tks very much for your post.

    Avoid surprises — interviews need preparation. Some questions come up time and time again — usually about you, your experience and the job itself. We've gathered together the most common questions so you can get your preparation off to a flying start.

    You also find all interview questions at link at the end of this post.

    Source: Top 10 interview questions and answers

    Best rgs

  2. Excellent post!!! Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities. Java Course in Chennai | Best JAVA Training in Chennai

  3. The future of automation testing tool is on the positive tool. As the demand of quality web application keeps on increasing, the tool like Selenium IDE is getting very popular all over the world. Thus, taking Selenium Training in Chennai will help you to enter software testing industry. Best Selenium training institute in Chennai

  4. wow really nice. It will be helpful for the people those who are ready to crack the interview and please also for remind what they have learned throughout concept.

    SEO Training in Chennai

  5. I just want to say I’m new to weblog and certainly savored this page. Almost certainly I’m likely to bookmark your website . You actually have outstanding well written articles. Cheers for sharing with us your website.

    Seo Training in Chennai

  6. After looking into this blog on your site, I really like your technique of writing a blog. I bookmarked it to my bookmarking site list and will be checking back it for my future reference. Take a look at my website as well and let me know your opinion.
    Android training in chennai>

  7. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai

  8. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
    Digital Marketing Company in India

  9. Learning new technolgy would help oneself at hard part of their career. And staying updated is the only way to survive in current position. Your content tells the same. Thanks for sharing this information in here. Keep blogging like this. Android Training in Chennai

  10. Its very useful to me. Wonderful blog.. Thanks for sharing informative Post.

    Installment loans
    Payday loans
    Title loans


  11. Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way.Thank you so much

    Personal Installment Loans
    Payday Cash Advance loan
    Title Car loan
    Cash Advance Loan

  12. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

  13. Candid institute Spring and Hibernate course provides a comprehensive introduction to Spring and Hibernate open source frameworks as well as Web Services and AJAX. Suitable for both Spring3/Hibernate3 and Spring4/Hibernate4, the course includes coverage of the core Spring and Hibernate capabilities, as well as the integration capabilities provided by Spring.
    Spring boot training

  14. The Spring Framework is a lightweight framework for developing Java enterprise applications. It provides high performing, easily testable and reusable code. Spring handles the infrastructure as the underlying framework so that you can focus on your application.Spring is modular in design, thereby making creation, handling and linking of individual components so much easier. Spring implements Model View Container(MVC) design pattern.
    spring mvc validation example

  15. Thanks for sharing this good blog.This is very important and imformative blog for Java . very interesting and usefulblog
    Java Online Training Hyderabad

  16. I read your blog it's really good, thanks for sharing valuable information with us.
    Excellent Article, Nice to read your article, very informative.
    Excellent article Top AC mechanics Professional Camera sellers ChennaiCatering Service in ChennaiTop Educational Institute Chennai

    Excellent Article
    swimmingpool contractor chennai
    swimmingpool equipment dealer chennai
    swimmingpool consultant chennai

  17. Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.

    Best Java Training Institute Chennai

  18. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

  19. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

  20. Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area.
    datascience training in chennai

  21. Outstanding blog post, I have marked your site so ideally I’ll see much more on this subject in the foreseeable future.

    java training in chennai | java training in bangalore

    java online training | java training in pune

  22. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

    rpa training in Chennai | rpa training in pune

    rpa training in tambaram | rpa training in sholinganallur

    rpa training in Chennai | rpa training in velachery

    rpa online training | rpa training in bangalore

  23. Good Post, I am a big believer in posting comments on sites to let the blog writers know that they ve added something advantageous to the world wide web.
    python training in rajajinagar
    Python training in btm
    Python training in usa

  24. Really very nice blog information for this one and more technical skills are improve,i like that kind of post.
    DevOps online Training
    DevOps Training in USA

  25. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.

    Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies

    Selenium Training in Bangalore | Best Selenium Training in Bangalore

    AWS Training in Bangalore | Amazon Web Services Training in Bangalore

  26. Thanks for sharing this valuable information to our vision. You have posted a worthy blog keep sharing.

    Guest posting sites

  27. Thank you for sharing such great information with us. I really appreciate everything that you’ve done here and am glad to know that you really care about the world that we live in
    Java training in Bangalore | Java training in Marathahalli | Java training in Bangalore | Java training in Btm layout

    Java training in Bangalore | Java training in Marathahalli | Java training in Bangalore | Java training in Btm layout

  28. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    Best Devops Training in pune | Java training in Pune

  29. Fantastic work! This is the type of information that should follow collective approximately the web. Embarrassment captivating position Google for not positioning this transmit higher! Enlarge taking place greater than and visit my web situate
    Python training course in Chennai | Data science training in pune | Data science online training

  30. Thank you for this brief explanation and ver nice information. well, got a good knowledge. Have a nice idea, this is more helpful to me.

    Corporate Training in Chennai | Corporate Training Courses | Corporate Training in Adyar | Corporate Training in Velachery | Corporate Training in Tambaram

  31. many of us have developed some nice methods, and we are looking to trade methods with others, why not shoot me an e-mail if interested.
    nebosh course in chennai

  32. You have provided a nice article, Thank you very much for this. I hope this will be useful for many people. Please keep on updating these type of blogs with good content.Thank You...
    aws online training
    aws training in hyderabad
    amazon web services(AWS) online training
    amazon web services(AWS) training online

  33. Hey there! I know this is kind of off-topic, but I’d figured I’d ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa?
    safety course in chennai

  34. Your post is really awesome. Your blog is really helpful for me to develop my skills in a right way. Thanks for sharing this unique information with us.
    - Learn Digital Academy

  35. Nice blog..! I really loved reading through this article. Thanks for sharing such
    a amazing post with us and keep blogging...Well written article Thank You for Sharing with Us pmp training Chennai | pmp training centers in Chenai | pmp training institutes in Chennai | pmp training and certification in Chennai | pmp training in velachery

  36. You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us

    angularjs Training in bangalore

    angularjs interview questions and answers

    angularjs Training in marathahalli

    angularjs interview questions and answers

    angularjs-Training in pune

  37. Such an excellent and interesting blog, do post like this more with more information, this was very useful, Thank you.
    airport ground staff training courses in chennai
    airport ground staff training in chennai
    ground staff training in chennai

  38. Thanks for such a great article here. I was searching for something like this for quite a long time and at last, I’ve found it on your blog. It was definitely interesting for me to read about their market situation nowadays. Well written article Thank You for Sharing with Us pmp training fee | | project management training in chennai | project management certification online | project management course online |

  39. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Online DevOps Certification Course - Gangboard
    Best Devops Training institute in Chennai

  40. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving.Most of ideas can be nice content.The people to give them a good shake to get your point and across the command
    python training institute in marathahalli
    python training institute in btm
    Python training course in Chennai