Java Interview Questions for Freshers

Java Interview Questions for Freshers, Java Environment setup, Java Language Fundamentals, Control Flow, and Object-Oriented Programming.

Java is a general-purpose programming language, to be used for writing software in the widest variety of application domains.

Java Programming language was developed in 1995 at Sun Microsystems, later Java was acquired by Oracle in 2010.

Java Interview Questions for Freshers

1. Is Java a Platform?

Java is a programming language and a platform.

A platform is the hardware or software environment in which a piece of software is executed. Java provides a software-based platform.

2. What do you understand by Java virtual machine?

The Java code is compiled by JVM (Java Virtual Machine) to be a Bytecode that is machine-independent and close to the native code.

JVM enables the computer to run the Java program. It acts like a run-time engine which calls the main method present in the Java code.

3. What is the difference between JDK, JRE, and JVM?

JVM is an acronym for Java Virtual Machine; it is an abstract machine which provides the runtime environment in which Java bytecode can be executed.

The Java Runtime Environment, or JRE, is a software layer that runs on top of a computer’s operating system software and provides the class libraries and other resources that a specific Java program needs to run.

JDK is an acronym for Java Development Kit. It is a software development environment which is used to develop Java applications and applets.

Note: JDK contains JRE and JRE contains JVM, so JDK is a full software of Java

4. What are the important Editions of Java Programming?

There are four platforms of the Java programming language:

1. Standard Edition (Java SE) or Core Java
2. Enterprise Edition (Java EE) or Advanced Java
3. Micro Edition (Java ME)
4. JavaFX.

5. What is JIT compiler?

The Just-In-Time (JIT) compiler is a an essential part of the JRE i.e. Java Runtime Environment, that is responsible for performance optimization of java based applications at run time.

6. Is Java ‘WORA’ in nature?

Java supports ‘WORA’ – Write once run ant where.

Java compiler converts the Java programs into the class file (Byte Code) which is the intermediate language between source code and machine code. This bytecode is not platform-specific and can be executed on any computer.

7. Why is Java not a pure object-oriented language?

In Java, everything is an object, Ex: String is an object, Array is Object, and ArrayList is object, but Java primitive data types – byte, short, int, long, float, double, char, and are not objects, so Java is not a pure object-oriented language.

8. Pointers are used in C/ C++. Why does Java not make use of pointers?

Pointers are quite complicated and unsafe to use by beginner programmers. Java focuses on code simplicity, and the usage of pointers can make it challenging. Pointer utilization can also cause potential errors. Moreover, security is also compromised if pointers are used because the users can directly access memory with the help of pointers.

9. What are the various access specifiers for Java classes?

In Java, access specifiers are the keywords used before a class name that defines the access scope. The types of access specifiers for classes are:

1. Public: Class, Method, Field is accessible from anywhere.

2. Protected: Method, Field can be accessed from the same class to which they belong or from the sub-classes,and from the class of same package,but not from outside.

3. Default: Method, Field, the class can be accessed only from the same package and not from outside of it’s native package.

4. Private: Method, Field can be accessed from the same class to which they belong.

10. What are Java Class members?

Every single thing which are in the scope of the class is called class members, not only in java but this can also be applied in other programming languages.

Two important Java class members are:

1. Member Variables (States)
2. Methods (Behaviors)

11. What is the main() method in Java?

A main() method in java is an entry point to start the execution of a program. Every Java application has at least one class and at least one main method.

12. Can we declare the main() method of our class as private?

In Java, the 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.

13. When the constructor of a class is invoked?

The constructor of a class is invoked every time an object is created with new keyword.

14. Is String a data type in Java?

String class (predefined) is used to store text-type data. The string is not a primitive data type in java. When a string is created in java, it’s actually an object of Java.Lang.

15. What is multi-threading?

Multithreading is a programming concept to run multiple tasks in a concurrent manner within a single program. Threads share the same process stack and run in parallel. It helps in the performance improvement of any program.

16. How garbage collection is done in Java?

In java, when an object is not referenced anymore, garbage collection takes place and the object is destroyed automatically. For automatic garbage collection java calls either System.gc() method or Runtime.gc() method.

Java Complete Tutorial

Java Videos

Java Programming Language Syllabus
1. Introduction to Java Programming

2. Java Environment Setup

3. Java Keywords and Identifiers

4. Java Basic Syntax

5. Java Program Structure.

6. Comments in Java

7. Modifiers in Java.

8. Java Data Types.

9. Variables in Java.

10. Operators in Java

11. Java Decision Making Statements

12. Java Loop Statements

13. Java Branching Statements

14. Java Strings

15. Java Arrays

16. Java ArrayList

17. Read User Input

18. File Handing/File Operations

19. Java User-Defined Methods

20. Java Built-in Methods

21. Exception Handling in Java

22. Java Object-Oriented Programming

23. Java Inheritance

24. Polymorphism in Java

25. Abstraction in Java

Types of Output in Java Programming

Follow me on social media: