Java For Beginners Lec 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Advanced Object Oriented

Programming
Lecture 01
Java Language
• Java is a human readable programming language, which is strictly
class based and object oriented. The language syntax is deliberately
modeled on that of C and C++ and it was explicitly intended to be
familiar to programmers coming from those languages.
• Java is related to C++, which is a direct descendant of C. Much of the
character of Java is inherited from these two languages. From C, Java
derives its syntax. Many of Java’s object-oriented features were
influenced by C++.
History of Java
• Java was developed by James Gosling at Sun Microsystems, Inc. in
1991. It took 18 months to develop the first working version.
• This language was initially called “Oak,” but was renamed “Java” in
1995.
• Java was created on the principles like Robust, Portable, Platform
Independent, High Performance, Multithread, etc.
What Is the JVM?
• The JVM is a program that provides the runtime environment necessary for
Java programs to execute. Java programs cannot run unless there is a JVM
available for the appropriate hardware and OS platform we wish to execute
on.
• The JVM has been ported to run on a large number of environments—
anything from a set-top box or Blu-ray player to a huge mainframe will
probably have a JVM available for it.
• When the JVM takes in a Java program for execution, the program is not
provided as Java language source code. Instead, the Java language source
must have been converted (or compiled) into Java bytecode. Java bytecode
must be supplied to the JVM in a format called class files (which always
have a .class extension).
JVM….
• The JVM provides an execution environment for the program. It starts
an interpreter for the bytecode form of the program that steps
through one bytecode instruction at a time. However, production
JVMs also provide a runtime compiler (JIT) that will accelerate the
important parts of the program by replacing them with equivalent
compiled machine code.
• Not all parts of a Java program are equally likely to be called during
the lifetime of the program—some portions will be called far, far
more often than others. The Java platform takes advantage of this
fact with a technology called justintime (JIT) compilation.
JVM…
• The JVM first identifies which parts of the program are called most
often the HotSpot “hot methods.” Then, the JVM compiles these hot
methods directly into machine code, bypassing the JVM interpreter.
Why Java
• Portable WORA (write once, run anywhere)
• Simple
• “Pure” Object Oriented Language
• Support for Distributed and Web Applications
• Rich Libraries
Multithreading, Swing, RMI, NET, SQL…
• Automatic Garbage Collection
• More Robust
Portable
• “write once, run anywhere” (WORA), is the property that Java class
files can be moved from one execution platform to another, and they
will run unaltered provided a JVM is available.
• A Java program can be developed (and converted to class files) on a
machine running macOS, and then the class files can be moved to
Linux or Microsoft Windows (or other platforms) and the Java
program will run without any further work needed.
Simple
• Similar to C/C++ in syntax
• In-fact Java is C++ minus
• operator overloading
• direct pointer manipulation or pointer arithmetic
• multiple inheritance
• Destructors (Garbage Collector– handles memory automatically)
Pure Object-Oriented
• Fundamentally based on OOP
• All functions belong to classes or objects. No global variables or
functions exist
• All classes by default inherit from a common ancestor known as
“Object”
• “Almost” all data types are objects
• Object-oriented programming (OOP) is at the core of Java. OOP is so
integral to Java that it is best to understand its basic principles before
you begin writing even simple Java programs.
Abstraction, Encapsulation
• Abstraction hides complexity by giving you a more abstract picture, a
sort of 10,000 feet view,
• While Encapsulation hides internal working so that you can change it
later.
• In other words,
• Abstraction hides details at the design level.
• While Encapsulation hides details at the implementation level.
Inheritance, Polymorphism
• Inheritance is a mechanism in which one object acquires all the
properties and behaviors of a parent object. It is an important part of
OOP (Object Oriented programming).
• Inheritance represents the IS-A relationship which is also known as a
parent-child relationship.

• Polymorphism is the ability of an object to take on many forms. The


most common use of polymorphism in OOP occurs when a parent
class reference is used to refer to a child class object.
Assignment:
• History of Java versions.

Thank You

You might also like