Java Interview Questions and Answers, Java Interview Questions and Answers Freshers, Java Interview Questions and Answers, Java Interview Questions

Before getting on to the Java interview questions, the student must know that the JAVA is a continuously varying field which needs the students as well as professionals to upgrade their skills with the new features and knowledge, to get fit for the jobs associated with Java. This post related to Java Interview Questions and Answers, Java Interview Questions and Answers Freshers, Java Interview Questions and Answers, Java Interview Questions will help you let out find all the solutions that are frequently asked in you upcoming Java interview.

Over thousands of vacancies available for the JAVA developers, experts must be acquaintance with all the component of JAVA technologies. This is necessary for the students in order to have in-depth knowledge of the subject so that they can have best employment opportunities in the future. Knowing every little detail about JAVA is the best approach to solve the problems linked to the problem.

APTRON has spent hours and hours in researching the Java Interview Questions and Answers, Java Interview Questions and Answers Freshers, Java Interview Questions and Answers, Java Interview Questions that you might encounter in your upcoming interview. This post related to JAVA interview questions and answers will help you let out find all the solutions that are frequently asked in you upcoming JAVA interview. All these questions will alone help you to crack the interview and make you the best among all your competitors.

First of all, let us tell you about how the JAVA technology is evolving in today’s world and how demanding it is in the upcoming years. In fact, according to one study, most of the companies and businesses have moved to the JAVA. Now, you cannot predict how huge the future is going to be for the people experienced in the related technologies.

Hence, if you are looking for boosting up your profile and securing your future, JAVA will help you in reaching the zenith of your career. Apart from this, you would also have a lot of opportunities as a fresher.

These questions alone are omnipotent. Read and re-read the questions and their solutions to get accustomed to what you will be asked in the interview. These JAVA interview questions and answers will also help you on your way to mastering the skills and will take you to the giant world where worldwide and local businesses, huge or medium, are picking up the best and quality JAVA professionals.

This ultimate list of best JAVA interview questions will ride you through the quick knowledge of the subject and topics like OOPS, SPRING, HIBERNATE. This JAVA interview questions and answers can be your next gateway to your next job as a JAVA expert.

These are very Basic JAVA Interview Questions and Answers for freshers and experienced both.

Q1: What are the important features of Java 8 release?
A1: Java 8 has been released in March 2014, so it’s one of the hot topic in java interview questions. If you answer this question clearly, it will show that you like to keep yourself up-to-date with the latest technologies.

Java 8 has been one of the biggest release after Java 5 annotations and generics. Some of the important features of Java 8 are:

1. Interface changes with default and static methods
2. Functional interfaces and Lambda Expressions
3. Java Stream API for collection classes
4. Java Date Time API

I strongly recommend to go through above links to get proper understanding of each one of them, also read Java 8 Features.

Q2: What do you mean by platform independence of Java?
A2: Platform independence means that you can run the same Java Program in any Operating System. For example, you can write java program in Windows and run it in Mac OS.

Q3: What is JVM and is it platform independent?
A3: Java Virtual Machine (JVM) is the heart of java programming language. JVM is responsible for converting byte code into machine readable code. JVM is not platform independent, thats why you have different JVM for different operating systems. We can customize JVM with Java Options, such as allocating minimum and maximum memory to JVM. It’s called virtual because it provides an interface that doesn’t depend on the underlying OS.

Q4: What is the difference between JDK and JVM?
A4: Java Development Kit (JDK) is for development purpose and JVM is a part of it to execute the java programs.

JDK provides all the tools, executables and binaries required to compile, debug and execute a Java Program. The execution part is handled by JVM to provide machine independence.

Q5: What is the difference between JVM and JRE?
A5: Java Runtime Environment (JRE) is the implementation of JVM. JRE consists of JVM and java binaries and other classes to execute any program successfully. JRE doesn’t contain any development tools like java compiler, debugger etc. If you want to execute any java program, you should have JRE installed.

Q6: Which class is the superclass of all classes?
A6: java.lang.Object is the root class for all the java classes and we don’t need to extend it.

Q7: Why Java doesn’t support multiple inheritance?
A7: Java doesn’t support multiple inheritance in classes because of “Diamond Problem”. To know more about diamond problem with example, read Multiple Inheritance in Java.

However multiple inheritance is supported in interfaces. An interface can extend multiple interfaces because they just declare the methods and implementation will be present in the implementing class. So there is no issue of diamond problem with interfaces.

Q8: Why Java is not pure Object Oriented language?
A8: Java is not said to be pure object oriented because it support primitive types such as int, byte, short, long etc. I believe it brings simplicity to the language while writing our code. Obviously java could have wrapper objects for the primitive types but just for the representation, they would not have provided any benefit.

As we know, for all the primitive types we have wrapper classes such as Integer, Long etc that provides some additional methods.

Q9: Explain public static void main(String args[]).
A9: public : Public is an access modifier, which is used to specify who can access this method. Public means that this Method will be accessible by any Class.

static : It is a keyword in java which identifies it is class based i.e it can be accessed without creating the instance of a Class.

void : It is the return type of the method. Void defines the method which will not return any value.

main: It is the name of the method which is searched by JVM as a starting point for an application with a particular signature only. It is the method where the main execution occurs.

String args[] : It is the parameter passed to the main method.

Q10: What are constructors in Java?
A10: In Java, constructor refers to a block of code which is used to initialize an object. It must have the same name as that of the class. Also, it has no return type and it is automatically called when an object is created.

There are two types of constructors:

  1. Default constructor
  2. Parameterized constructor

Q11: What is singleton class and how can we make a class singleton?
A11: Singleton class is a class whose only one instance can be created at any given time, in one JVM. A class can be made singleton by making its constructor private.

Q12: What is the difference between Array list and vector?
A12:

Array List Vector
Array List is not synchronized. Vector is synchronized.
Array List is fast as it’s non-synchronized. Vector is slow as it is thread safe.
If an element is inserted into the Array List, it increases its Array size by 50%. Vector defaults to doubling size of its array.
Array List does not define the increment size. Vector defines the increment size.
Array List can only use Iterator for traversing an Array List. Except Hashtable, Vector is the only other class which uses both Enumeration and Iterator.

Q13: What are the differences between Heap and Stack Memory?
A13: The major difference between Heap and Stack memory are:

Features Stack Heap
Memory Stack memory is used only by one thread of execution. Heap memory is used by all the parts of the application.
Access Stack memory can’t be accessed by other threads. Objects stored in the heap are globally accessible.
Memory Management Follows LIFO manner to free memory. Memory management is based on generation associated to each object.
Lifetime Exists until the end of execution of the thread. Heap memory lives from the start till the end of application execution.
Usage Stack memory only contains local primitive and reference variables to objects in heap space. Whenever an object is created, it’s always stored in the Heap space.

Q14: What is the difference between double and float variables in Java?
A14: In java, float takes 4 bytes in memory while Double takes 8 bytes in memory. Float is single precision floating point decimal number while Double is double precision decimal number.

Q15: What is Final Keyword in Java? Give an example.
A15: In java, a constant is declared using the keyword Final. Value can be assigned only once and after assignment, value of a constant can’t be changed.

In below example, a constant with the name const_val is declared and assigned avalue:

Private Final int const_val=100

When a method is declared as final,it can NOT  be overridden by the subclasses.This method are faster than any other method,because they are resolved at complied time.

When a class is declares as final,it cannot be subclassed. Example String,Integer and other wrapper classes.

Q16: How can you generate random numbers in Java?
A16:

  • Using Math.random() you can generate random numbers in the range greater than or equal to 0.1 and less than 1.0
  • Using Random class in package java.util

Q17: Can we declare the main method of our class as private?
A17: In java, main method must be public static in order to run any application correctly. If main method is declared as private, developer won’t get any compilation error however, it will not get executed and will give a runtime error.

Q18: How can we pass argument to a function by reference instead of pass by value?
A18: In java, we can pass argument to a function only by value and not by reference.

Q19: How an object is serialized in java?
A19: In java, to convert an object into byte stream by serialization, an interface with the name Serializable is implemented by the class. All objects of a class implementing serializable interface get serialized and their state is saved in byte stream.

Q20: When we should use serialization?
A20: Serialization is used when data needs to be transmitted over the network. Using serialization, object’s state is saved and converted into byte stream .The byte stream is transferred over the network and the object is re-created at destination.

Q21: Can a class have multiple constructors?
A21: Yes, a class can have multiple constructors with different parameters. Which constructor gets used for object creation depends on the arguments passed while creating the objects.

Q22: What is an applet?
A22: An applet is a small java program that runs inside the browser and generates dynamic contents.

Q23: Can you write a Java class that could be used both as an applet as well as an application?
A23: Yes. Add a main() method to the applet.

Q24: What is Locale?
A24: A Locale object represents a specific geographical, political, or cultural region.

Q25: How will you load a specific locale?
A25: By ResourceBundle.getBundle(?) method.

Q26: What is a JavaBean?
A26: are reusable software components written in the Java programming language, designed to be manipulated visually by a software development environment, like JBuilder or VisualAge for Java.

Q27: Can RMI and Corba based applications interact?
A27: Yes they can. RMI is available with IIOP as the transport protocol instead of JRMP.

Q28: What is the difference between yielding and sleeping?
A28: When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

Q29: Why Vector class is used?
A29: The Vector class provides the capability to implement a growable array of objects. Vector proves to be very useful if you don’t know the size of the array in advance, or you just need one that can change sizes over the lifetime of a program.

Q30: How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
A30: Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.

Q31: What are Wrapper classes?
A31: These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.

Q32: What is the difference between a Window and a Frame?
A32: The Frame class extends Window to define a main application window that can have a menu bar.

Q33: What is meant by binding in RMI?
A32: Binding is the process of associating or registering a name for a remote object, which can be used as a further, in order to look up that remote object. A remote object can be associated with a name using the bind / rebind methods of the Naming class.

Q34: What are latest features introduced with Java 8?
A34: The below latest features are introduced in Java 8. Lambda Expressions, Interface Default and Static Methods, Method Reference, Parameters Name, Optional Streams, Concurrency.

Q35: Name few Java 8 annotations?
A35:
1. @Functional Interface annotation

2. @Repeatable annotation,

@Functional Interface annotation: It was introduced in Java SE 8, indicates that the type declaration is intended to be a functional interface, as defined by the Java Language Specification.@Repeatable annotation: introduced in Java SE 8, indicates that the marked annotation can be applied many times to the same declaration or type use.

Q36: Distinguish between a predicate and a function?
A36: A predicate takes one argument and returns a Boolean value.

A function takes one argument and returns an object.

Both are useful for evaluating lambda expressions.

JAVA Conclusion Interview FAQs

We know the list of Java Interview Questions and Answers, Java Interview Questions and Answers Freshers, Java Interview Questions and Answers, Java Interview Questions is overwhelming but the advantages of reading all the questions will maximize your potential and help you crack the interview. The surprising fact is that this JAVA interview questions and answers post covers all the basic of the JAVA technology and you have to check out the FAQs of different components of JAVA too.

However, you will be asked with the questions in the interview related to the above mentioned questions. Preparing and understanding all the concept of JAVA technology will help you strengthen the other little information around the topic.

After preparing these interview questions, we recommend you to go for a mock interview before facing the real one. You can take the help of your friend or a JAVA expert to find the loop holes in your skills and knowledge. Moreover, this will also allow you in practicing and improving the communication skill which plays a vital role in getting placed and grabbing high salaries.

Remember, in the interview, the company or the business or you can say the examiner often checks your basic knowledge of the subject. If your basics is covered and strengthened, you can have the job of your dream. The industry experts understand that if the foundation of the student is already made up, it is easy for the company to educate the employ towards advance skills. If there are no basics, there is no meaning of having learnt the subject.

Therefore, it’s never too late to edge all the basics of any technology. If you think that you’ve not acquired the enough skills, you can join our upcoming batch of JAVA Training in Noida. We are one of the best institute for JAVA in noida which provide advance learning in the field of JAVA Course. We’ve highly qualified professionals working with us and promise top quality education to the students.

We hope that you enjoyed reading Java Interview Questions and Answers, Java Interview Questions and Answers Freshers, Java Interview Questions and Answers, Java Interview Questions and all the FAQs associated with the interview. Do not forget to revise all the JAVA interview questions and answers before going for the JAVA interview. In addition to this, if you’ve any doubt or query associated with JAVA, you can contact us anytime. We will be happy to help you out at our earliest convenience. At last, we wish you all the best for your upcoming interview on JAVA Technology.

LEAVE A REPLY

Please enter your comment!
Please enter your name here