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

Simula is considered the first object

Uploaded by

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

Simula is considered the first object

Uploaded by

Cristine Versoza
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Simula is considered the first object-oriented As the name suggests, Object-Oriented Programming or OOPs

programming language. The programming paradigm refers to languages that uses objects in programming. Object-
where everything is represented as an object is known as a oriented programming aims to implement real-world entities like
truly object-oriented programming language. inheritance, hiding, polymorphism in programming.

Smalltalk is considered the first truly object-oriented Objects and Classes


programming language.
Class is the basic concept of OOP; an extended concept of the
The popular object-oriented languages are Java, C#, PHP, structure used in C. It is an abstract and user-defined data type. It
Python, C++, etc. consists of several variables and functions. The primary purpose
The main aim of object-oriented programming is to of the class is to store data and information.
implement real-world entities, for example, object, classes,
The members of a class define the behavior of the class. A class is
abstraction, inheritance, polymorphism, etc.
the blueprint of the object, but also, we can say the
implementation of the class is the object. The class is not visible
What is Object Oriented Programming? to the world, but the object is.

Object means a real-world entity such as a pen, chair, table, Object


computer, watch, etc. Object-Oriented Programming is a  Any entity that has state and behavior is known as an
methodology or paradigm to design a program using classes and object. For example, a chair, pen, table, keyboard, bike,
objects. It simplifies software development and maintenance by etc. It can be physical or logical.
providing some concepts:
 An Object can be defined as an instance of a class. An
o Object object contains an address and takes up some space in
o Class memory. Objects can communicate without knowing the
o Inheritance details of each other's data or code. The only necessary
o Polymorphism thing is the type of message accepted and the type of
o Abstraction response returned by the objects.
o Encapsulation Class
 Collection of objects is called class. It is a logical entity.
 A class can also be defined as a blueprint from which you  Binding (or wrapping) code and data together into a single
can create an individual object. Class doesn't consume any unit are known as encapsulation. For example, a capsule, it
space. is wrapped with different medicines.
 A java class is the example of encapsulation. Java bean is
Inheritance the fully encapsulated class because all the data members
 When one object acquires all the properties and behaviors are private here.
of a parent object, it is known as inheritance. It provides
code reusability. It is used to achieve runtime Advantage of OOPs over Procedure-oriented programming
polymorphism. language

Polymorphism 1. OOPs makes development and maintenance easier,


 If one task is performed in different ways, it is known as whereas, in a procedure-oriented programming language,
polymorphism. For example: to convince the customer it is not easy to manage if code grows as project size
differently, to draw something, for example, shape, increases.
triangle, rectangle, etc.
 In Java, we use method overloading and method 2. OOPs provides data hiding, whereas, in a procedure-
overriding to achieve polymorphism. oriented programming language, global data can be
 Another example can be to speak something; for example, accessed from anywhere.
a cat speaks meow, dog barks woof, etc.
Abstraction 3. OOPs provides the ability to simulate real-world event
 Hiding internal details and showing functionality is known much more effectively. We can provide the solution of real
as abstraction. For example, phone call, we don't know the word problem if we are using the Object-Oriented
internal processing. Programming language.
 In Java, we use abstract class and interface to achieve
abstraction. Object Oriented Programming in Java

Java is one of the most popular and widely used programming


language and platform. A platform is an environment that helps to
develop and run programs written in any programming language.
Encapsulation Java is fast, reliable and secure.
From desktop to web applications, scientific supercomputers to  Java programming is object-oriented programming
gaming consoles, cell phones to the Internet, Java is used in every language.
nook and corner.  Like C++ java provides most of the object-oriented
features.
History of Java  Java is pure OOP language. (while C++ is semi
object oriented)
Initially java language is named as “Oak” in 1991, which is 3. It is platform independent.
designed for the consumer electronic appliances like toasters and  Unlike other programming languages such as C, C++
refrigerators. Later in 1995 the name was changed to Java. Java etc. which are compiled into platform specific
was developed by James Gosling, a development leader in sun machines, Java language is guaranteed to be write-
micro system. Oak was redesigned in 1995 and changed the name once, run-anywhere language.
to java for the development of the applications which can be run  On compilation Java program is compiled into
over internet. Using the java language, java programs can be bytecode. This bytecode is platform independent and
embedded in to the html pages. Java is not only limited for the can be run on any machine, and this bytecode format
web applications; it is also useful to develop the stand-alone also provide security.
applications. Java has a feature called OOPs, which make it more 4. It is robust.
familiar. Object oriented programming replaced the old traditional  Java encourages error-free programming by being
techniques i.e. procedural programming. strictly typed and performing run-time checks.
5. It supports multi-threading.
One of the first projects developed using Java was a personal  Java provides integrated support for multithreaded
hand-held remote control named Star 7. programming.
6. High Performance.
Characteristics of Java  Bytecodes are highly optimized.
 JVM can executed them much faster.
1. Java is a simple language. 7. It offers strong security.
 Java is Easy to write and more readable and eye  Java program cannot harm other system thus making
catching. it secure.
 Java has a concise, cohesive set of features that  Java provides a secure means of creating Internet
makes it easy to learn and use. applications.
 Most of the concepts are drew from C++ thus  Java provides secure way to access web applications.
making Java learning simpler. 8. It is a portable language.
2. It has an object-oriented model.
 Java programs can execute in any environment for packages, which includes basic language classes, GUI component
which there is a Java run-time system. (JVM) classes and so on. The other main deployment environment is on
 Java programs can be run on any platform (Linux, your web browser. Most commercial browsers supply a Java
Windows, Mac) technology interpreter and runtime environment.
 Java programs can be transferred over world wide
web (e.g. applets) Java Source File Structure

The Java Environment

What is Java Technology?

The Java Technology is:


• A programming language
• A development environment
• An application environment
• A deployment environment

As a programming language, Java can create all kinds of


applications that you could create using any conventional
programming language.

As a development environment, Java technology provides you  Each Java source file must have the same name as a public
with a large suite of tools; a compiler, an interpreter, a class that it declares.
documentation generator, a class file packaging tool, and so on.  Each Java source file can contain only one public class
declaration.
Java technology applications are typically general-purpose
 The file extension must be .java.
programs that run on any machine where the Java Runtime
Environment (JRE) is installed.  The filename is case-sensitive. Therefore, the preceding
source code must be stored in a file named NewClass.java.
There are two main deployment environments: First, the JRE Phases of Java Program
supplied by the Java 2 Software Development Kit (SDK) contains
the complete set of class files for all the Java technology
Task Tool to Use Output
Write the program Any text File w/ .java extension
editor
Compile the Java compiler File w/ .class extension (Java
program bytecodes)
Run the program Java Program Output The .class file is then interpreted by the Java interpreter that
interpreter converts the bytecodes into the machine language of the particular
The following figure describes the process of compiling and computer you are using.
executing a Java program.
Summary of the Phases of Java Program
Compilation
In Java, programs are not compiled into executable files; they are
compiled into bytecode (as discussed earlier), which the JVM
The first step in creating Java program is by writing your (Java Virtual Machine) then executes at runtime. Java source code
programs in a text editor. Examples of text editors you can use are is compiled into bytecode when we use the javac compiler. The
notepad, vi, emacs, etc. this file is stored in a disk file with the bytecode gets saved on the disk with the file extension .class.
extension .java. When the program is to be run, the bytecode is converted, using
the just-in-time (JIT) compiler. The result is machine code which
After creating and saving your Java program, compile the is then fed to the memory and is executed.
program by using the Java Compiler. The output of this process is
a file of Java bytecodes with the file extension class. Java code needs to be compiled twice in order to be executed:

A bytecode is a special machine language that can be understood 1. Java programs need to be compiled to bytecode.
by the Java Virtual Machine (JVM). The bytecode is independent 2. When the bytecode is run, it needs to be converted to
of any particular computer hardware, so any computer with a Java machine code.
interpreter can execute the compiled Java program, no matter The Java classes/bytecode are compiled to machine code and
what type of computer the program was compiled on. loaded into memory by the JVM when needed the first time. This
The Java Virtual Machine is an imaginary machine that is is different from other languages like C/C++ where programs are
implemented by emulating software on a real machine. The JVM to be compiled to machine code and linked to create an executable
provides the hardware platform specifications to which you file before it can be executed.
compile all Java Technology code. This specification enables the
Java software to be platform-independent because the compilation
is done for a generic machine known as the JVM.

You might also like