0% found this document useful (0 votes)
4 views

java interview questiona

Java

Uploaded by

nebeno2624
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

java interview questiona

Java

Uploaded by

nebeno2624
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java Interview Questions for Freshers

Before we move on to the next part, if you would like to explore JAVA through a
self-paced course, you can take up GUVI’s JAVA course with certification.

Java Interview Questions for Freshers

* What is Java?

* Answer: Java is a high-level, object-oriented programming


language known for its platform independence and versatility. It
was developed by Sun Microsystems (now Oracle) in 1995. Java
programs can run on any platform that has a Java Virtual
Machine (JVM) installed, making it highly portable.

* What are the key features of Java?

* Answer:

* Platform Independence: Java's "Write Once, Run Anywhere"


(WORA) principle allows Java programs to run on any operating
system with a JVM.

* Object-Oriented: Java is based on the concept of objects,


which encapsulate data and behavior.

* Robust: Java incorporates features like exception handling


and strong type checking to minimize errors and improve
program reliability.

* Secure: Java has built-in security mechanisms that help


prevent malicious code execution.

* Multithreaded: Java supports concurrent execution of


multiple threads within a single program, enabling efficient use of
CPU resources.

* What is the JVM (Java Virtual Machine)?


* Answer: The JVM is an abstract machine that provides the
runtime environment for executing Java bytecode. It acts as an
intermediary between the Java program and the underlying
operating system. The JVM translates Java bytecode (the
output of the Java compiler) into machine-specific code that
can be understood by the host operating system.

* Differentiate between JDK, JRE, and JVM.

* Answer:

* JDK (Java Development Kit): This is the comprehensive


software development kit that includes everything you need to
develop and run Java programs. It contains the JRE, compilers,
debuggers, and other development tools.

* JRE (Java Runtime Environment): The JRE is a subset of the


JDK and provides the necessary libraries and components to run
Java programs. It includes the JVM and other essential runtime
libraries.

* JVM (Java Virtual Machine): As explained earlier, the JVM is


the core component that executes Java bytecode.

* Explain the difference between a class and an object in Java.

* Answer:

* Class: A class is a blueprint or template that defines the


properties (attributes) and behaviors (methods) of a set of
objects. It's like a blueprint for a house, specifying the number of
rooms, windows, etc.

* Object: An object is an instance of a class. It represents a


specific entity with its own unique set of values for the
attributes defined in the class. For example, a specific house
built from the blueprint would be an object.
* What is object-oriented programming (OOP)?

* Answer: OOP is a programming paradigm that organizes


software around "objects" that contain both data and methods
(functions) to operate on that data. Key principles of OOP
include:

* Encapsulation: Grouping data and methods that operate on


that data within a single unit (class).

* Inheritance: Creating new classes (subclasses) from existing


ones (superclasses), inheriting their properties and behaviors.

* Polymorphism: The ability of objects of different classes to


be treated as objects of a common type.

* Abstraction: Hiding complex implementation details and


presenting only essential features to the user.

* List and briefly explain the four fundamental principles of OOP.

* Answer:

* Encapsulation: Grouping data (attributes) and methods


(behaviors) within a single unit (class) and controlling access to
them. This helps protect data integrity and reduces the risk of
unintended modifications.

* Inheritance: Creating new classes (subclasses) from existing


ones (superclasses). Subclasses inherit properties and behaviors
from their parent class, promoting code reusability and reducing
redundancy.

* Polymorphism: The ability of objects of different classes to


be treated as objects of a common type. This allows for more
flexible and adaptable code.
* Abstraction: Hiding the internal implementation details of a
class and presenting only the essential features to the user. This
simplifies the use of the class and reduces complexity.

* What is inheritance in Java?

* Answer: Inheritance is a mechanism that allows one class


(subclass or derived class) to inherit properties and methods
from another class (superclass or base class). This promotes
code reusability and helps organize classes in a hierarchical
manner. For example, a "Dog" class might inherit properties and
behaviors from a more general "Animal" class.

* What is encapsulation in Java?

* Answer: Encapsulation is the principle of bundling data


(attributes) and methods (behaviors) that operate on that data
within a single unit (class). By controlling access to the internal
data of a class (using access modifiers like public, private,
protected), encapsulation helps protect data integrity and
reduces the risk of unintended modifications.

I hope these answers are helpful!

* https://medium.com/@mohamedgamalmohamed48/the-
power-of-composition-over-inheritance-in-swift-
programming-
18a6545607ce?responsesOpen=true&sortBy=REVERSE_CHRON

You might also like