Java

Home > Preview

The flashcards below were created by user Tbone on FreezingBlue Flashcards.


  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 java.io.Serializable 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 Interfaces.you 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
    Synchronization or Thread Safe :  This is the most important difference between two . HashMap is non synchronized and not thread safe.On the other hand, HashTable is thread safe and synchronized.

    Null keys and null values :  Hashmap allows one null key and any number of null values, while Hashtable do not allow null keys and null values in the HashTable object.
  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

Card Set Information

Author:
Tbone
ID:
319796
Filename:
Java
Updated:
2016-07-12 13:31:29
Tags:
Java
Folders:

Description:
Java Interview Questions
Show Answers:

Home > Flashcards > Print Preview