Home > Preview
The flashcards below were created by user
on FreezingBlue Flashcards.
What are the
principle concepts of OOPS
Abstraction, Polymorphism, Inheritance, Encapsulation
What is polymorphism
One Interface, many implementations. Ability for an entity to have more than one form.
What is Abstraction?
Abstraction refers to the act of representing essential features without including the background details or explanations.
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.
What is Inheritance
Inheritance is the process by which objects of one class acquire the properties of objects of another class.
How does Java implement polymorphism
Inheritance, Overloading and Overriding
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.
Is it possible to override the main method?
NO, because main is a static method. A static method can't be overridden in Java.
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.
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.
What are the differences between Class Methods and Instance Methods?
Class methods are methods which are declared as static.
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.
What are Access Specifiers available in Java
- Default (only accessible in same package, not subclasses in different package)
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.
What is the difference between Enumeration and Iterator
Enumeration is read-only
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.
Difference between ArrayList and Vector
- Vector is synchronized.
- Vector can use enumeration
- ArrayList has no default size
What is the Set interface
Collection that does not allow duplicate elements.
What are the main Implementations of the Map interface
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.
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
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.
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.
what is an immutable object
an object that can not be modified after it is created.
String, Integer, Double, Float are all immutable.
what are the primitive data types
byte, short, int, long, float, double, boolean, char
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.
What is the difference between StringBuffer and StringBuilder?
StringBuffer is synchronized, StringBuilder is not.
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)
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
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.
What types of Dependency Injection does Spring support?
- Setter Injection
- Constructor Injection
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
What is ORM?
Object/relational mapping. The automated persistence of objects in a java application to the tables in a relational database
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.
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.
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