Card Set Information

2016-05-09 10:31:21

Java Interview Questions
Show Answers:

  1. What are the
    principle concepts of OOPS
    Abstraction, Polymorphism, Inheritance, Encapsulation
  2. What is polymorphism
    One Interface, many implementations.  Ability for an entity to have more than one form.
  3. What is Abstraction?
    Abstraction refers to the act of representing essential features without including the background details or explanations.
  4. What is Encapsulation
    Encapsulation is a technique used for hiding the properties and behaviors of an object and allowing outside access only as appropriate. It prevents other objects from directly altering or accessing the properties or methods of the encapsulated object.
  5. What is Inheritance
    Inheritance is the process by which objects of one class acquire the properties of objects of another class.
  6. How does Java implement polymorphism
    Inheritance, Overloading and Overriding

    Factory pattern
  7. Explain the different forms of Polymorphism
    There are two types of polymorphism one is Compile time polymorphism and the other is run time polymorphism. Compile time polymorphism is method overloading. Runtime time polymorphism is done using inheritance and interface.
  8. Is it possible to override the main method?
    NO, because main is a static method. A static method can't be overridden in Java.
  9. What is a marker interface?
    Marker interfaces are those which do not declare any required methods, but signify their compatibility with certain operations. The interface and Cloneable are typical marker interfaces.
  10. When should I use abstract classes and when should I use interfaces?
    Use Interfaces when…You see that something in your design will change frequently.If various implementations only share method signatures then it is better to use need some classes to use some methods which you don't want to be included in the class, then you go for the interface, which makes it easy to just implement and make use of the methods defined in the interface.Use Abstract Class when…If various implementations are of the same kind and use common behavior or status then abstract class is better to use.When you want to provide a generalized form of abstraction and leave the implementation task with the inheriting subclass.Abstract classes are an excellent way to create planned inheritance hierarchies. They're also a good choice for nonleaf classes in class hierarchies.
  11. What are the differences between Class Methods and Instance Methods?
    Class methods are methods which are declared as static.
  12. How are this() and super() used with constructors?
    • Constructors use this to refer to another constructor in the same class with a different parameter list.
    • Constructors use super to invoke the superclass's constructor. If a constructor uses super, it must use it in the first line; otherwise, the compiler will complain.
  13. What are Access Specifiers available in Java
    • Public
    • Protected
    • Default (only accessible in same package, not subclasses in different package)
    • Private
  14. What are the uses of final method?
    Disallowing subclasses to change the meaning of the method.

    Increasing efficiency by allowing the compiler to turn calls to the method into inline Java code.
  15. What is the difference between Enumeration and Iterator
    Enumeration is read-only
  16. What are the main implementations of the List interface
    ArrayList : Resizable-array implementation of the List interface. The best all-around implementation of the List interface.

    Vector : Synchronized resizable-array implementation of the List interface

    LinkedList : Doubly-linked list implementation of the List interface. May provide better performance than the ArrayList implementation if elements are frequently inserted or deleted within the list.
  17. Difference between ArrayList and Vector
    • Vector is synchronized.
    • Vector can use enumeration
    • ArrayList has no default size
  18. What is the Set interface
    Collection that does not allow duplicate elements.
  19. What are the main Implementations of the Map interface
    • HashMap
    • HashTable
    • TreeMap
    • EnumMap
  20. Difference between HashMap and Hashtable
    HashMap lets you have null values as well as one null key.

    Hashtable is synchronized.
  21. How do you sort an ArrayList (or any list) of user-defined objects
    the objects in the list have an implementation of java.lang.Comparable.

    put comparison logic in compareTo implemented method
  22. What is the difference between Set, Map and List
    lists are ordered, and you can have duplicates.

    Sets are unordered, and you can't have duplicates.

    Maps are key-value pairs, rather than just a collection of items. You can have duplicate values, but not duplicate keys.
  23. what is an anonymous inner class
    creating an instance of an interface that also implements required methods inline with the code.  accomplishes the same thing as creating a class that imlplements the interface, then instantiating that class.

    Have used in APIs that use ActionListener to add event processing to buttons and such.
  24. what is an immutable object
    an object that can not be modified after it is created.

    String, Integer, Double, Float are all immutable.
  25. what are the primitive data types
    byte, short, int, long, float, double, boolean, char
  26. Does Java pass by reference or pass by value?
    Java passes by value.  A copy of the original value is sent to the method.  If you alter the value of the value in the method, the original value will also change as the copy changes.
  27. What is the difference between StringBuffer and StringBuilder?
    StringBuffer is synchronized, StringBuilder is not.
  28. What is dependency injection (inversion of control)?
    objects are given their dependencies at creation time by an external entity. ie Spring application context file(s)
  29. What are the different types of dependency injection?
    • Constructor Injection: Dependencies are provided as constructor parameters
    • Setter Injection: Dependencies are assigned through JavaBeans properties (setters)
    • Interface Injection: Injection is done through an Interface
  30. What are the benefits of dependency injection?
    • Minimizes the amount of code in your application
    • Makes your application more testable.  Allows you to inject your own objects into the object being tested (mocking)
    • Loose coupling is promoted
    • Supports eager instantiation and lazy loading.
  31. What types of Dependency Injection does Spring support?
    • Setter Injection
    • Constructor Injection
  32. What is the Spring Application Context?
    • It loads the beans, wires them together, and dispenses the beans upon request
    • Resolves text messages
    • Loads file resources
  33. What is ORM?
    Object/relational mapping. The automated persistence of objects in a java application to the tables in a relational database
  34. What is Aspect Oriented Programming?
    A programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns.  It can add behavior to existing code without modifying the code itself.  It allows behaviors that are not central to the business logic to be added to a system without cluttering the code core to functionality.  Examples are logging and transaction management.
  35. What are some of the concepts of AOP?
    • Aspect: a modularization of a concern that cuts across multiple classes
    • Join Poin: a point during code execution, like a method invocation or an exception being thrown
    • Advice: action taken by an aspect at a particular join point (before, after, around)
    • Pointcut: A predicate that matches join points.  (controls when an advice executes)
    • AOP proxy: an object created by the AOP framework in order to implement the aspect contracts.
  36. What is a proxy object?
    An instance of an object that acts as a pass through to the real object.  Used to modify or add to the behavior of the object.  Used by Hibernate for lazy loading entities and Spring AOP
  37. What are the Hibernate object states
    • Transient: Instantiated, but not associated to a Hibernate session.  It is not associated to a database object.
    • Persistent: Associated to a database object and changes to this object will be synced with the database.
    • Detached: An object that was persistent, but the Hibernate session has been closed.
  38. What is the difference between Set and Bag in hibernate?
    A set is associated to a set in Java, therefore it is unordered and may contain no duplicates.  A bag maps to a List in Java and may contain duplicates.
  39. Tell me about yourself
    • Years of experience
    • Roles and responsibilities at RKV
    • End-to-end development of web based business applications
    • Batch processing and web services
    • List frameworks and APIs
    • List domain experience
    • Graphic design, database architect, sql optimization, mobile friendly web design.
  40. What is your biggest weakness
    Public speaking
  41. Why did you leave your last company?
    • Wipro: Did not like the environment after integration.  Benefits nor the companies business approach.  Did not feel they would win the next contract
    • RKV:  Can't pass up the opportunity at Cerner and president of company may be retiring soon
  42. Where do you see yourself in 5 years?
    Working at Cerner.  I see myself in some sort of technical lead role that involves application design and still a lot of development.  I see myself as a mentor to junior programmers both as a technical resource and a subject matter expert.  I also plan to have my Java certification and be attending tech conferences on a regular basis.
  43. Tell me about a time where you handled a difficult situation.
    The lady that kept reverting back to her own solution.  Solved the problem by doing paired programming.
  44. Why should we hire you?
    • My skills match the Cerner technology stack very closely.
    • Extensive experience with requirements gathering and communicating with clients
    • Domain knowlege
    • Enjoy what I do and take pride in my work
    • I have a lot of knowledge but I know there is still a lot to learn
    • Confident but I am also open to the best idea, even if it not my own.
  45. Tell me about a time you failed.
    Florida alligator hunt.
  46. Tell me about a time you were on a tight deadline.
    • Because deadlines are usually hard and fixed, most every project feels that way.
    • New emomed project.  
    • Tell them about the project and the team we had.
    • I was bottleneck because I was trying to do too much
    • Not utilizing talents of team members effectively
    • We prioritized tasks with the customer.
  47. Tell me about a time when you had a conflict at work.
    • Haven't had any real conflicts to speak of.  I try not to let too many things bother me,  it usually just isn't worth it.  My friend calls me "the oak".
    • Only example would be Sanjay.
  48. Tell me about a time where you were part of a dysfunctional team.
    • Emomed team.  Team of mostly contractors.  One really good, but mostly mediocre.
    • We weren't always sent the person we interviewed on the phone.
    • One was bringing the team down.
    • One that wasn't so good at innovating solutions.
    • Had to let one go, but for the others we identified what they were good at and gave them assignments that played to those strengths