Basic Java Interview Questions You Must Read Today
For any professional in any technology, it is of utmost importance to be aware of all the buzzwords. Also, one must know the technology completely in and out, including the most commonly asked interview questions. To help individuals with the same, we have compiled some of the top Java Interview Questions so that you can bring down all of them to their knees at the time of interview. Before moving ahead, we would like to make it clear that this one carries the first set of basic questions for Java Interview. So, here we go -
Que 1 - Is Java platform independent? If yes, then why?
Yes, Java is platform-independent and it is regarded as such because al its bytes codes will simply run on any system no matter what the operating system is.
Que 2 - Is Java not 100% Object-oriented?
No, Java is not 100% object-oriented as it utilized 8 types of data like byte, boolean, int, char, double, float, short and long.
Que 3 - Can you explain the singleton class in Java and how can one create a class singleton?
It is one of those classes whose one instance can be created at a point of time, i.e., in one JVM. By making it's constructor private, you can simply make the class singleton.
Que 4 - Why aren’t the pointers utilized in Java?
Since the pointers are unsafe and only make the program complex, Java doesn’t use them. Java is known for its code simplicity, however, the addition of pointers will be contradicting. Furthermore, JVM is held accountable for the implicit memory allocation, therefore, pointers are not used in Java to avoid direct memory access by the user.
Que 5 - What do you mean by constructor chaining in Java?
Constructor chaining is a process that helps in calling one constructor from another by considering the current object. This procedure is only possible via legacy. Here a subclass constructor is held accountable for invoking the constructor of the superclass. There can be various kinds of classes in the constructor chain. This process can only be achieved in two ways:
Within the same class using this()
From base class using super()
Que 6 - What is a classloader in Java?
A subset of JVM (Java Virtual Machine), Java ClassLoader is responsible for loading the files of the class. Irrespective of the time when the Java program is executed, it is primarily loaded by the classloader. There are three built-in classloaders provided by Java:
1. Bootstrap ClassLoader
2. System/Application ClassLoader
3. Extension ClassLoader
Que 7 - Why Java Strings are immutable?
In Java, string items are unchanging which essentially implies once the String article is made its state can't be altered. At whatever point you attempt to refresh the estimation of that item as opposed to refreshing the estimations of that specific article, Java makes another string object. Java String articles are changeless as String items are by and large stored in the String pool. Since String literals are typically shared between various customers, activity from one customer may influence the rest. It upgrades security, reserving, synchronization, and execution of the application.
Que 8 - What do you mean by a Map in Java?
In Java, Map is an interface of Util bundle which maps interesting keys to values. The Map interface isn't a subset of the fundamental Collection interface and hence it carries on minimal not quite the same as the other collection types. Following are some of the characteristics of Map interface:
1. It does not have duplicate keys.
2. All the keys can map at max value of one.
Que 9 - What is the collection class in Java? Name some of methods and interfaces.
The collection is a structure that goes about as engineering for putting away and controlling a gathering of articles. Utilizing Collections you can perform different errands like searching, arranging, inclusion, control, erasure, and so forth. Following are included in the Java collection framework -
Que 10 - What do you understand by Object-Oriented Programming?
OOPs is a programming model or approach where the projects are composed around articles as opposed to rationale and capacities. As such, OOP, for the most part, centers around the articles that are required to be controlled rather than rationale. This methodology is perfect for the projects enormous and complex codes and should be effectively refreshed or kept up.
Que 11 - What are the main concepts of OOPs in Java?
Object-Oriented Programming is a programming style which is linked to concepts like:
1. Inheritance: It is where one class gains the properties of another.
2. Encapsulation: It is an instrument of wrapping up the information and code all together unit.
3. Abstraction: It is the technique of concealing the execution subtleties from the client and just giving the usefulness to the clients.
4. Polymorphism: A variable, capacity or item can take various structures.
Que 12 – Can you differentiate between a local variable and an instance variable?
A local variable is regularly utilized inside a strategy, constructor, or a square and has just nearby scope. Subsequently, this variable can be utilized uniquely inside the extent of a square. The best advantage of having a neighborhood variable is that different strategies in the class won't be ever mindful of that variable. For example -
if(x > 100)
String test = "Edureka";
While, an example variable in Java, is a variable which is limited to its article itself. These factors are pronounced inside a class, however outside a technique. Each object of that class will make its duplicate of the variable while utilizing it. In this way, any progressions made to the variable won't reflect in some other occurrences of that class and will be bound to that specific occasion as it were. For example -
public String EmpName;
public int empAge;
Read some other Job interview questions with answers of other topics:
- ServiceNow interview questions
- Python Interview Questions
- Power BI Interview Questions
- Hadoop MapReduce Interview Questions
- DevOps Engineer Interview Questions
- BizTalk Certification Questions
- Workday Interview Questions
- Salesforce Interviews Questions
- Pega Interview Questions
- Microsoft .NET Interview Questions
- Data Science Interview questions
- Business Analyst Interview Questions
- Android App Development Certification