Q-1: What is Java?
Java is a high-level, robust, object-oriented,
and secure, and stable programming language. Java was developed by James Gosling,
Patrick Naughton, Mike Sheridan at Sun Microsystems Inc. in 1991. To develop
the first version, it takes 18 months.
The first name of this new language is Oak but
in 1995 it's renamed called java.
Q-2: Writes the
features of Java?
The main features
of java are-
1) Simple
2) Object-Oriented
3) Platform Independent
4) Secure & Portable
5) Multi-Threading
6) High Performance
7) Architectural Neutral
Q-3: What Is
Object-Oriented Programming?
Object-oriented
programming is a way of organizing programs as a collection of objects, each of
which represents an instance of a class.
Q-4: Define a Java
Class?
A class in Java is
a blueprint that includes all your data. A class contains fields (variables)
and methods to describe the behavior of an object.
Q-5: What is
an object?
The Object is the
real-time entity having some state and behavior. In Java, an object is an
instance of the class having the instance variables like the state of the
object and the methods as the behavior of the object.
Q-6: Why Java is
not 100% Object-oriented?
Java is not 100%
Object-oriented because it makes use of eight primitive data types such as
boolean, byte, char, int, float, double, long, short which are not objects.
Q-7: Write the limitations of OOPs?
It takes longer to solve the problem. Proper planning is required. Programmers should think about solving a problem in the context of objects that are generally not suitable for small problems.
Q-8: What is JVM?
Why is Java called the Platform Independent Programming Language?
A Java virtual machine (JVM) is a process virtual machine
that can execute Java bytecode. Each Java source file is compiled into a
bytecode file, which is executed by the JVM. Java was designed to allow
application programs to be built that could be run on any platform, without
having to be rewritten or recompiled by the programmer for each separate
platform. A Java virtual machine makes this possible, because it is aware of
the specific instruction lengths and other particularities of the underlying
hardware platform.
Q-9: What is the Difference between JDK and JRE ?
The Java Runtime
Environment (JRE) is basically the Java Virtual Machine (JVM) where your Java
programs are being executed. It also includes browser plugins for applet
execution. The Java Development Kit (JDK) is the full featured Software
Development Kit for Java, including the JRE, the compilers and tools (like Javadoc, and Java Debugger), in order for a user to develop, compile and
execute Java applications.
Q-10: What are the basic concepts of OOP?
The four basic concepts of OOP
are:
a.) Abstraction
b.) Polymorphism
c.) Inheritance
d.) Encapsulation
Q-11: What is
Encapsulation?
- ·
It is a technique to hide the
properties and behaviors of an object.
- ·
The access is provided only as
required.
- ·
It prevents other objects from
altering or accessing the properties of an encapsulated object.
Q-12: What is
Abstraction?
The abstraction
technique aims to separate the implementation details of a class from its behavior.
Q-13: What are the Differences between Abstraction and
Encapsulation?
Abstraction and
encapsulation are complementary concepts. On the one hand, abstraction focuses
on the behavior of an object. On the other hand, encapsulation focuses on the
implementation of an object’s behavior. Encapsulation is usually achieved by
hiding information about the internal state of an object and thus, can be seen
as a strategy used in order to provide abstraction.
Q-14: What is Inheritance?
· The class that inherits is called sub-class while the class from which the object is inherited is called superclass.
· Inheritance helps in re-using the code and polymorphism.
Q-15: What is Function Overriding and Overloading in Java?
Method overloading in Java occurs when two or more methods
in the same class have the exact same name, but different parameters. On the
other hand, method overriding is defined as the case when a child class
redefines the same method as a parent class. Overridden methods must have the
same name, argument list, and return type. The overriding method may not limit
the access of the method it overrides.
Q-16: What is the difference between an Interface and an
Abstract class?
Java provides and
supports the creation both of abstract classes and interfaces. Both
implementations share some common characteristics, but they differ in the
following features:
• All methods in an interface are implicitly abstract. On
the other hand, an abstract class may contain both abstract and non-abstract
methods.
• A class may
implement a number of Interfaces, but can extend only one abstract class.
• In order for a
class to implement an interface, it must implement all its declared methods.
However, a class may not implement all declared methods of an abstract class.
Though, in this case, the sub-class must also be declared as abstract.
• Abstract classes can implement interfaces without even
providing the implementation of interface methods.
• Variables declared in a Java interface is by default
final. An abstract class may contain non-final variables.
• Members of a Java interface are public by default. A
member of an abstract class can either be private, protected or public.
• An interface is absolutely abstract and cannot be
instantiated. An abstract class also cannot be instantiated, but can be invoked
if it contains a main method.
Q-17: Define polymorphism?
Polymorphism in Java is a concept by which we
can perform a single action in different ways. Polymorphism has come from 2
greek words: poly and morphs. The word "poly" means many and
"morphs" means forms. So, polymorphism means many forms. In simple
words "The word polymorphism means having many forms".
Example: - Real-life example of polymorphism:
A person at the same time can have different characteristic. As women at the
same time is a mother, a wife, an employee. So, the same person possess
different behaviour in different situations. This is called polymorphism.
Q-18: Define Compile time Polymorphism and Runtime
Polymorphism in java?
Compile-time Polymorphism: - Polymorphism which is resolved during compiler
time is known as static polymorphism or Compile time polymorphism. Method
overloading is an example of compile-time polymorphism.
Runtime Polymorphism: - Runtime polymorphism is a process in which a
call to an overridden method is resolved at runtime, that's why it is called
runtime polymorphism. An example of runtime polymorphism is method
overriding.
Q-19: What is a class
loader in Java?
The Java Class
Loader is a subset of JVM (Java Virtual Machine) that is responsible for
loading the class files. Whenever a Java program is executed, it is first
loaded by the class loader.
Q-20: What are
wrapper classes in Java?
Wrapper classes
convert the Java primitives into the reference types (objects). Every primitive
data type has a class dedicated to it.
Q-21: What are
access modifiers in Java?
In Java, access
modifiers are special keywords that are used to restrict the access of a
class, constructor, data member, and method in another class.
Java supports
four types of access modifiers:
1. Default
2. Private
3. Protected
4. Public
👉Java Exception handling Interview Questions and Answers
👉Java Collection Framework Interview questions for Freshers
👉Java9 Interview Questions & Answers for beginners
👉Java8 Interview Questions & Answers for beginners
0 Comments