Difference between String literal and New String object in Java?
String strObject = new String("Java");
and
String strLiteral = "Java";
Both expression gives you String object, but there is subtle difference between them. When you create String object using new() operator, it always create a new object in heap memory. On the other hand, if you create object using String literal syntax e.g. "Java", it may return an existing object from String pool (a cache of String object in Perm gen space, which is now moved to heap space in recent Java release), if it's already exists. Otherwise it will create a new string object and put in string pool for future re-use.
Collection basic interface and Classes?
What are Different Spring type annotation?
Context Configuration Annotations
Stereotyping Annotations
Spring MVC Annotations
Transaction Annotations
Aspect Annotations
Read More : https://dzone.com/refcardz/spring-annotations
What is the alternate for @restcontroller annotation?
@RestController is a convenience annotation that combines @Controller and @ResponseBody.By annotating the controller class with @RestController annotation, you no longer need to add @ResponseBody to all the request mapping methods.To use @RestController in our example, all we need to do is modify the @Controller to @RestController and remove the @ResponseBody from each method.
Difference between SendRedirect() and Forward() in JSP Servlet?
What is Annotation and what is the purpose/use of annotation?
Java annotations are used to provide meta data for your Java source code. Being meta data, Java annotations do not directly affect the execution of your code.
Java Annotation Purposes
Java annotations are typically used for the following purposes:
- Compiler instructions
- Build-time instructions
- Runtime instructions
Instructions to the compiler: There are three built-in annotations available in Java (@Deprecated, @Override & @SuppressWarnings) that can be used for giving certain instructions to the compiler. For example the @override annotation is used for instructing compiler that the annotated method is overriding the method.
Polymorphism in java?
Polymorphism in java is a concept by which we can perform a single action by different ways. Polymorphism is derived from 2 greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means many forms.
There are two types of polymorphism in java: compile time polymorphism and runtime polymorphism. We can perform polymorphism in java by method overloading and method overriding.
If you overload static method in java, it is the example of compile time polymorphism.
OOPS Concepts in Java
Core OOPS concepts are:
- Abstraction
- Encapsulation
- Polymorphism
- Inheritance
- Association
- Aggregation
- Composition
Association, Composition and Aggregation in Java
How set check the uniqueness of elements?
Why we use Hibernate Template in Spring?
All spring templates (hibernate, jdbc, rest, jpa etc.) have the same pros and cons:
Pro: They perform common setup routines for you, let you skip the boilerplate and concentrate on the logic you want.
Con: you are coupling your application tightly to the spring framework. For this reason, Spring recommends that HibernateTemplate no longer be used.
Specifically, what HibernateTemplate did for you was to automatically open and close sessions and commit or rollback transactions after your code executed.
Whats the difference between Hashtable and concurrentHashMap as both are thread safe?
Read From : http://codepumpkin.com/hashtable-vs-synchronizedmap-vs-concurrenthashmap/
LEFT JOIN in mysql and sytax of join?
The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side, if there is no match.
SELECT column_name(s)
FROM table1
LEFT JOIN table2 ON table1.column_name = table2.column_name;
Prototype object in spring are statefull or stateless?
Stateless beans: beans that are singleton and are initialized only once. The only state they have is a shared state. These beans are created while the ApplicationContext is being initialized. The SAME bean instance will be returned/injected during the lifetime of this ApplicationContext.
stateful beans: beans that can carry state (instance variables). These are created EVERY time an object is required (like using the "new" operator in java).
Which collection you would prefer for fast fechting of data?
Every collection type is suitable for a particular scenario. There is no fastest or best collection.
If you need fast access to elements using index, ArrayList is your answer.
If you need fast access to elements using a key, use HashMap.
If you need fast add and removal of elements, use LinkedList (but it has a very poor index access performance).
and so on.
Explain Spring Architecture?
- DispatcherServlet receives the request.
- DispatcherServlet dispatches the task of selecting an appropriate controller to HandlerMapping. HandlerMapping selects the controller which is mapped to the incoming request URL and returns the (selected Handler) and Controller to DispatcherServlet.
- DispatcherServlet dispatches the task of executing of business logic of Controller to HandlerAdapter.
- HandlerAdapter calls the business logic process of Controller.
- Controller executes the business logic, sets the processing result in Model and returns the logical name of view to HandlerAdapter.
- DispatcherServlet dispatches the task of resolving the View corresponding to the View name to ViewResolver. ViewResolver returns the View mapped to View name.
- DispatcherServlet dispatches the rendering process to returned View.
- View renders Model data and returns the response.
Read More: http://terasolunaorg.github.io/guideline/1.0.1.RELEASE/en/Overview/SpringMVCOverview.html
Explain Hibernate Architecture?
Difference between abstraction and encapsulation?
Abstraction: Abstraction means hiding the internal details and just exposing the functionality.
Encapsulation: Encapsulation means wrapping relevant data in a class and controlling its access.
The most important difference between Abstraction and Encapsulation is that Abstraction solves the problem at design level while Encapsulation solves it implementation level.
In Java, Abstraction is supported using interface and abstract class while Encapsulation is supported using access modifiers e.g. public, private and protected.
Abstraction focus on outer lookout e.g. moving of vehicle while Encapsulation focuses on internal working or inner lookout e.g. how exactly the vehicle moves.
Abstraction - hiding implementation.
encapsulation - hiding data
Read more: http://javarevisited.blogspot.com/2017/04/difference-between-abstraction-and-encapsulation-in-java-oop.html#ixzz51pV0Ic16
Abstraction: Abstraction means hiding the internal details and just exposing the functionality.
Encapsulation: Encapsulation means wrapping relevant data in a class and controlling its access.
The most important difference between Abstraction and Encapsulation is that Abstraction solves the problem at design level while Encapsulation solves it implementation level.
In Java, Abstraction is supported using interface and abstract class while Encapsulation is supported using access modifiers e.g. public, private and protected.
Abstraction focus on outer lookout e.g. moving of vehicle while Encapsulation focuses on internal working or inner lookout e.g. how exactly the vehicle moves.
Abstraction - hiding implementation.
encapsulation - hiding data
Read more: http://javarevisited.blogspot.com/2017/04/difference-between-abstraction-and-encapsulation-in-java-oop.html#ixzz51pV0Ic16
No comments:
Post a Comment