Professional Documents
Culture Documents
Introduction
Welcome to the course Object Oriented
Programming in JAVA. This course will cover a
core set of computer science concepts needed
to create a modern software application using
Java.
1990 Sun Microsystems decided to develop special software that could be used
to manipulate consumer electronic devices. A team of Sun Microsystems
Features of Java :
The bytecode is the result of compiling a Java program. You can execute this
code on any platform. In other words, due to the bytecode compilation process
and interpretation by a browser, Java programs can be executed on a variety of
hardware and operating systems. The only requirement is that the system
should have a java-enabled Internet browser.The java compiler is written in
Java, and the interpreter is written in C. The Java Interpreter can execute Java
Code directly on any machine on which a Java interpreter has been installed.
Java Compiler
Application Type
Applet Type
Java
Java
Enabled
Interpreter
Browser
Output Output
Shape
The class Shape defines a method called getArea() that returns the area of a
shape. However, this method is not implemented by that class. Therefore, it is an
abstract method and Shape is an abstract class.
This means that no objects of class Shape can be created. However, the
functionality of that class can be inheritated by its subclass. The various
subclasses of Shape like Ellipse,Rectangle,Triangle do implement the getArea()
method.
12/07/2022 Unit 2 Programming in JAVA 18
How is Java different from C…
• C Language:
– Major difference is that C is a structure oriented language and
Java is an object oriented language and has mechanism to
define classes and objects.
– Java does not support an explicit pointer type
– Java does not have preprocessor, so we cant use #define,
#include and #ifdef statements.
– Java does not include structures, unions and enum data types.
– Java does not include keywords like goto, sizeof and typedef.
– Java adds labeled break and continue statements.
– Java adds many features required for object oriented
programming.
Though C++ and java supports Boolean data type, C++ takes
any nonzero value as true and zero as false. True and false in
java are predefined literals that are values for a boolean
expression.
Java has replaced the destructor function with a finalize()
function.
C++ supports exception handling that is similar to java's.
However, in C++ there is no requirement that a thrown
exception be caught.