You are on page 1of 6

Assignment No.

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.

JRE is the superset of JVM.

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.

Q2.Explain steps involved in execution of Java program (Draw Diagram)?

Java program execution follows 5 major steps

 Edit - Here the programmer uses a simple editor or a notepad


application to write the java program and in the end give it a ".java"
extension.
 Compile - In this step, the programmer gives the javac command and
the .java files are converted into bytecode which is the language
understood by the Java virtual machine (and this is what makes
Java platform independent language).Any compile time errors are
raised at this step.
 Load - The program is then loaded into memory. This is done by the
class loader which takes the .class files containing the bytecode and
stores it in the memory. The .class file can be loaded from your hard
disk or from the network as well.
 Verify - The bytecode verifier checks if the bytecode loaded are valid
and do not breach java security restrictions.
 Execute - The JVM interprets the program one bytecode at a time and
runs the program.
Q3.Expain Characteristics of Object oriented language?

Now, let us discuss some of the main features of Object Oriented


Programming which you will be using in C++ (technically).

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.

How to define a class in Java?

Here's how we can define a class in Java:

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;
}
}

Here, we have created a class named Lamp.

The class has one variable named  isOn  and two


methods  turnOn()  and  turnOff() . These variables and methods defined within
a class are called members of the class.
In the above example, we have used keywords  private  and  public . These are
known as access modifiers. To learn more, visit Java access modifiers.

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:

className object = new className();

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.

Let's see how we can create objects of the  Lamp  class.

// 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

You might also like