Q10 How To Integrate Spring And Hibernate Frameworks
We can use Spring ORM module to integrate Spring and Hibernate frameworks if you are using Hibernate 3+ where SessionFactory provides current session, then you should avoid using HibernateTemplate or HibernateDaoSupport classes and better to use DAO pattern with dependency injection for the integration.
Also, Spring ORM provides support for using Spring declarative transaction management, so you should utilize that rather than going for hibernate boiler-plate code for transaction management.
Java Doesn’t Support Multiple Inheritance Why
Java doesnt support multiple inheritance because we cannot use different methods in one class it creates an ambiguity.Example:
class Intellipaat1}class Intellipaat2}Multiple inheritanceclass C extends Intellipaat1, Intellipaat2
Intellipaat1 and Intellipaat2 test methods are inheriting to class C. So, which test method class C will take?
As Intellipaat1 and Intellipaat2 class test methods are different, here we would face ambiguity.
Q7 Can You Explain The Java Thread Lifecycle
The java thread lifecycle has the following states-
When a thread is created, and before the program starts the thread, it is in the new state. It is also referred to as a born thread.
When a thread is started, it is in the Runnable state. In this state, the thread is executing its task.
Sometimes, a thread goes to the waiting state, where it remains idle because another thread is executing. When the other thread has finished, the waiting thread again comes into the running state.
In timed waiting, the thread goes to waiting state. But, it remains in waiting state for only a specified interval of time after which it starts executing.It remains waiting either till the time interval ends or till the other thread has finished.
A thread is said to be in this state once it terminates. It may be because the thread has completed its task or due to any other reason.
Recommended Reading: How To Watch Meghan And Harry Interview
How Do Cookies Work In Servlets
Cookies are the text files sent by the server and get stored in the client system to keep the information on the local machine and use it for tracking purposes. Java Servlet supports HTTP cookies through javax.servlet.http.Cookie class that implements cleanable and serializable interfaces.
The server sends a set of cookies to the client computer, for example, name, age, etc. Then, the browser stores the information in the local machine and sends these cookies to the server, if any request is sent to the webserver. This information can then be used to identify the user.
Q42 Why Java Strings Are Immutable In Nature
In Java, string objects are immutable in nature which simply means once the String object is created its state cannot be modified. Whenever you try to update the value of that object instead of updating the values of that particular object, Java creates a new string object. Java String objects are immutable as String objects are generally cached in the String pool. Since String literals are usually shared between multiple clients, action from one client might affect the rest. It enhances security, caching, synchronization, and performance of the application.
You May Like: What Are Common Questions Asked In A Job Interview
How Is Jsp Better Than Servlet Technology
JSP is a technology on the servers side to make content generation simple. They are document-centric, whereas servlets are programs. A Java server page can contain fragments of Java program, which execute and instantiate Java classes. However, they occur inside an HTML template file. It provides the framework for the development of a Web Application.
What Are Filters In Angular Name A Few Of Them
Filters are used to format an expression and present it to the user. They can be used in view templates, controllers, or services. Some inbuilt filters are as follows.
- date – Format a date to a specified format.
- filter – Select a subset of items from an array.
- Json – Format an object to a JSON string.
- limitTo – Limits an array/string, into a specified number of elements/characters.
- lowercase – Format a string to lowercase.
Q7 What Are The Different Types Of Inheritance In Java
Java supports four types of inheritance which are:
What Do You Understand By Scope In Angular
Recommended Reading: How To Do An Exit Interview
Q14 What Is Composition In Java
Composition is again a specialized form of Aggregation and we can call this as a death relationship. It is a strong type of Aggregation. Child object does not have their lifecycle and if parent object deletes all child object will also be deleted. Lets take again an example of a relationship between House and rooms. House can contain multiple rooms there is no independent life of room and any room can not belongs to two different houses if we delete the house room will automatically delete.
Q15. What is a marker interface?
A Marker interface can be defined as the interface having no data member and member functions. In simpler terms, an empty interface is called the Marker interface. The most common examples of Marker interface in Java are Serializable, Cloneable etc. The marker interface can be declared as follows.
public interface Serializable
Q16. What is object cloning in Java?
How To Prepare For Java Interview
Java is one of the rapidly growing programming languages worldwide. Most of the companies are chosen Java to build Desktop, Web, and Mobile applications. Product-based companies such as Google, Amazon, Facebook, or Microsoft have a different way to take Java interviews in comparison to the traditional programming interviews.
To crack the Java interview, we should have knowledge of Data structures and Algorithms like String and Java. The questions are easier and mostly based on practical work. The questions are related to the Java programming language and JDK API.
The questions are also related to the OOPs concept because Java is based on OOPs. So, we should also have great knowledge about the OOPs concepts. Java is mostly used as an application programming language, so the focus is mostly aligned with the questions related to API, Java concepts, and design patterns.
The level of Java interview depends on the experience you have. If you are a fresher applicant, the interview process and questions are not tricky, straightforward, and to the point. On the other hand, if you are an experienced guy and have experience of more than two years, the interview process and questions are tricky and not straightforward. Most questions are based on Java’s advanced concept, such as swings, API, and AWT.
You May Like: How To Give A Good Interview
Java Crash Course For Beginners 2022
How to Enroll This Course for Free :
- Introduction to Java Programming Language
- Getting Started With Java Arrays ,Values and Data Types, Operators and Operands
- Java Various Operator types, Java Array Lists, Java Conditional statements, Java decision making
- Java function statements and Java loops, various Java loops used in combinations
- Learning Java stack class
course Description :
- this course gets you started with an introduction to Java. It assumes that you’re new to the language, so it gets you started with basic functionality such as creating functions, creating variables,
- Master the fundamentals of writing Java code
- Discover how to work with sequence data
- Write Java functions to facilitate code reuse
- Use Java to read and write files
- Make their code robust by handling errors and exceptions properly
- Search text using regular expressions
- The topics covered in this course are: *Java course contents:
- Java introduction
What Are Template Statements
Template statements are properties or methods used in HTML for responding to user events. With these template statements, the application that you create or are working on, can have the capability to engage users through actions such as submitting forms and displaying dynamic content.
< button =”deleteHero”> Delete hero< /button>
The template here is deleteHero. The method is called when the user clicks on the button.
You May Like: How To Record An Interview On Iphone
Q11 How To Create A Custom Exception
To create you own exception extend the Exception class or any of its subclasses.
- class New1Exception extends Exception // this will create Checked Exception
- class NewException extends IOException // this will create Checked exception
- class NewException extends NullPonterExcpetion // this will create UnChecked exception
Which Topics To Prepare For Java Interviews
Java is an ocean of concepts. There are various concepts on which the interviewer can ask questions. We told you before that the level of the questions depends on the experience you have. For a fresher guy, the question can be related to the Java fundamentals like String, Collections, hashcode, API, and OOPs. The question for an experienced guy can be related to the same topics but can be too trivial for them.
All the Java developers who are serious about interviews should have knowledge of the concept as mentioned above. If we want to work in a company that develops applications based on core Java multithreading, we should know the core Java topics like multithreading and concurrency. Enum, Collections, JVM internals, GC algorithms, and Generics.
There are several books and tutorials are available in the market. If you are a beginner and want to learn Java within 30 days, .
You May Like: Design Questions For Product Manager Interview
Explain Data Encapsulation In Java
Data encapsulation is a fundamental OOPs concept that wraps the data and code as a single unit. These variables and methods can only be accessed through the current class, as theyll be hidden from others. Encapsulation protects the data from unnecessary modification and can be achieved in two ways:
- Using public setter and getter methods to view and modify the values
What Are The Important Benefits Of Using Hibernate Framework
Some of the important benefits of using hibernate framework are:
Overall hibernate is the best choice in current market for ORM tool, it contains all the features that you will ever need in an ORM tool.
Differentiate Between An Arraylist And A Vector
|An inner class is a class that is nested within another class.||A subclass is a class that inherits from another class called the superclass.|
|It provides the access rights for the class which is nesting it and that can access all variables and methods defined in the outer class.||It provides access to all public and protected methods and fields of its superclass.|
What Is A Request Dispatcher
The request dispatcher is an interface used to dispatch the requests to other resources like the Java Server Pages, image, HTML, or another servlet in the same application. It can also be used to include responses from one servlet to another so that the client gets the request from both servlets. Moreover, it can also be used to forward the client request to the next servlet.
There are two methods defined in a Requestdispatcher interface:
- void include: It includes the content of the resource before sending the response.
- void forward: the method forwards the request from one servlet to another resource like the JSP, image, etc on the server.
Don’t Miss: How To Conduct A Behavioral Interview
What Are Various Exception Handling Keywords In Java
Java language has three exception handling keywords:
- try: whenever a code segment has a chance of an error or any abnormality, it can be placed inside the try block. In case of any error, the try block will send the exception to the catch block.
- catch: catch handles the exception generated in the try block. It comes after the try block.
- final: The final keyword ensures that the segments execute despite the errors and exceptions processed by the try & catch block. The final keyword comes either after the try block or both the try and the catch block.
What Is The Difference Between Servletcontext Vs Servletconfig
The difference between ServletContext vs. ServletConfig is as follows:
|Similar to global parameters linked with the whole application.||Similar to local parameters associated with a particular servlet.|
|The ServletContext has an application-wide scope.||ServletConfig has the servlet wide scope.|
|To get the context object, getServletContext method is used.||To get the config object, getServletConfig is used.|
|Mainly used to get a MIME type of file or application.||Mainly used for specific users or tasks like the shopping card.|
Also Check: How To Ask About Salary In An Interview
Q11 What Is Encapsulation In Java
Encapsulation is a mechanism where you bind your data and code together as a single unit. Here, the data is hidden from the outer world and can be accessed only via current class methods. This helps in protecting the data from any unnecessary modification. We can achieve encapsulation in Java by:
- Providing public setter and getter methods to modify and view the values of the variables.
Q6 How Does An Exception Propagate In The Code
If an exception is not caught, it is thrown from the top of the stack and falls down the call stack to the previous procedure. If the exception isnt caught there, it falls back to the previous function, and so on, until its caught or the call stack reaches the bottom. The term for this is Exception propagation.
Q4 Explain Bean In Spring And List The Different Scopes Of Spring Bean
Beans are objects that form the backbone of a Spring application. They are managed by the Spring IoC container. In other words, a bean is an object that is instantiated, assembled, and managed by a Spring IoC container.
There are five Scopes defined in Spring beans.
- Singleton: Only one instance of the bean will be created for each container. This is the default scope for the spring beans. While using this scope, make sure spring bean doesnt have shared instance variables otherwise it might lead to data inconsistency issues because its not thread-safe.
- Prototype: A new instance will be created every time the bean is requested.
- Request: This is same as prototype scope, however its meant to be used for web applications. A new instance of the bean will be created for each HTTP request.
- Session: A new bean will be created for each HTTP session by the container.
- Global-session: This is used to create global session beans for Portlet applications.
In case you are facing any challenges with these java interview questions, please comment on your problems in the section below.
What Are Pure Pipes
These pipes are pipes that use pure functions. As a result of this, a pure pipe doesn’t use any internal state, and the output remains the same as long as the parameters passed stay the same. Angular calls the pipe only when it detects a change in the parameters being passed. A single instance of the pure pipe is used throughout all components.
You May Like: What Questions To Ask In A Second Interview