Assignment No.1: Q1.Explain Java Runtime Environment (JRE) ?
Assignment No.1: Q1.Explain Java Runtime Environment (JRE) ?
1
Q1.Explain Java Runtime Environment (JRE)?
JRE (Java Runtime Environment) is a software package that provides Java
class libraries, Java Virtual Machine (JVM), and other components that are
required to run Java applications.
If you need to run Java programs, but not develop them, JRE is what you
need. You can download JRE from Java SE Runtime Environment 8
Downloads page.
1. Objects
2. Classes
3. Abstraction
4. Encapsulation
5. Inheritance
6. Overloading
7. Exception Handling
Objects
Objects are the basic unit of OOP. They are instances of class, which have data
members and uses various member functions to perform tasks.
Class
It is similar to structures in C language. Class can also be defined as user defined
data type but it also contains functions in it. So, class is basically a blueprint for
object. It declare & defines what data variables the object will have and what
operations can be performed on the class's object.
Abstraction
Abstraction refers to showing only the essential features of the application and
hiding the details. In C++, classes can provide methods to the outside world to
access & use the data variables, keeping the variables hidden from direct access, or
classes can even declare everything accessible to everyone, or maybe just to the
classes inheriting it. This can be done using access specifiers.
Encapsulation
It can also be said data binding. Encapsulation is all about binding the data variables
and functions together in class.
Inheritance
Inheritance is a way to reuse once written code again and again. The class which is
inherited is called the Base class & the class which inherits is called
the Derived class. They are also called parent and child class.
So when, a derived class inherits a base class, the derived class can use all the
functions which are defined in base class, hence making code reusable.
Polymorphism
It is a feature, which lets us create functions with same name but different
arguments, which will perform different actions.
That means, functions with same name, but functioning in different ways. Or, it
also allows us to redefine a function to provide it with a completely new definition.
You will learn how to do this in details soon in coming lessons.
Exception Handling
Exception handling is a feature of OOP, to handle unresolved exceptions or errors
produced at runtime.
Q4.Define class and object?
Java Class
Before you create objects in Java, you need to define a class. A class is a
blueprint for the object.
We can think of the class as a sketch (prototype) of a house. It contains all the
details about the floors, doors, windows, etc. Based on these descriptions we
build the house. House is the object.
Since many houses can be made from the same description, we can create
many objects from a class.
class ClassName {
// variables
// methods
}
For example,
class Lamp {
// instance variable
private boolean isOn;
// method
public void turnOn() {
isOn = true;
}
// method
public void turnOff() {
isOn = false;
}
}
Java Objects
An object is called an instance of a class. For example, suppose Animal is a
class then Cat , Dog , Horse , and so on can be considered as objects
of Animal class.
Here is how we can create objects in Java:
Here, we are using the constructor className() to create the object.
Constructors have the same name as the class and are similar to methods. To
learn more about Java constructor, visit Java Constructors.
// l1 object
Lamp l1 = new Lamp();
// l2 object
Lamp l2 = new Lamp();
Here, we have created objects named l1 and l2 using the constructor
of Lamp class ( Lamp() ).
Objects are used to access members of a class.
Submission date:-20/07/2020