NASIR UMER
COMPUTER APPLICATIONS
Java / blue j
• A computer program is a collection of instructions that performs a specific
task when executed by a computer
• Programming language : Is nothing but set of instructions with their own
protocols/rules known as Syntax (correct way of writing program).
• Object Oriented Concepts
• Object and Class
• A class is a set of similar things (blueprint to create similar things)
like say a TATA Car
• The object can be Tata Nexon etc
• Object has attributes and functions
▪ E.g.: Attributes (Properties)- Height, colour etc.
▪ Functions- Accelerating, Applying brake etc.
Java
Java is developed by James Gosling in 1995. Earlier name was oak. Java is widely
used programming language. It is an OOP (object-oriented programming)
language. Java has both interpreter as well as compiler.
Types of programs:
1. Standalone (java application) : are stand-alone Java programs which do not
require any web browser to run. It is run by an Interpreter.
2. Internet applets (java applets) : is a little application and used to add small,
interactive components to a web page. It can be included in an HTML page.
1
NASIR UMER
COMPUTER APPLICATIONS
Features of java
1. OOP language
2. Uses both compiler and interpreter
3. Platform independent
4. WORA(write once run anywhere) – works on any operating system.
5. Case sensitive
6. Contains standalone and applet programs
7. Portable
8. Secure
9. Multithreaded
10.Robust (doesn’t crash easily)
Features of OOP
1. Stress given to data rather than functions
2. Programming is implemented using object.
Principles of OOP
Encapsulation
Abstraction
Polymorphism
Inheritance
2
NASIR UMER
COMPUTER APPLICATIONS
Object
Unique run time entity. Instance of a class. Identifiable entity with some
characteristics and behaviour. Memory is allocated when object is created. An
instance/object is created with the help of new operator which creates memory to
it.
Class
Is a blue print of an object. Is a set of similar objects. Class is prototype that
defines the variables and the methods common to all objects. No memory is
created to a class.
Class (object factory)
Without class object cannot be created. Many objects are created from the class
which is a template for the objects.
3
NASIR UMER
COMPUTER APPLICATIONS
Encapsulation (data hiding/class
Wrapping up of data and function into a single unit is called encapsulation(class)
Abstraction
Act of representing essential features without including background details
4
NASIR UMER
COMPUTER APPLICATIONS
Polymorphism (function overloading)
Is the process of using many functions with the common name but with different
parameters / data types / arguments. Can be implemented through function
overloading / construction overloading
Inheritance
Properties/behaviour of one class can be used(inherit) in another class. The class
from which properties/methods are derived is called as base/parent/super class. The
class deriving is called derived/child/sub class. The keyword extends is used for
inheritance.
5
NASIR UMER
COMPUTER APPLICATIONS
Source code
The program code(java programs) written by a programmer. After compilation
java creates object code(byte code)
Compiler
Translates whole source program(HLL) to object program(machine language/
LLL) not line-by-line. Translates the program all at once and then display the list
of errors.
Byte code
Java program is compiled in to an intermediate code, the platform independent
code.
JVM (Java Virtual Machine)
Byte code is independent of the machine on which the program is run. Jvm is a
virtual processor which processes the byte code to machine code instruction which
is uniform across all the platform.
6
NASIR UMER
COMPUTER APPLICATIONS
Interpreter
Translates source program to object program line-by-line. Halts at the occurance of
an error during the translation of source code to object code.
Jdk (java development kit - libraries) (API – Application Programming
Interface)
The Java Development Kit (JDK) is a software development environment used for
developing Java applications and applets. It includes JRE.
JDK java development kit
JRE java runtime
environment
JVM + LIBRARY CLASSES DEVELOPMENT TOOLS
CLASSES
Java Compilation Process
Step 1 : compiler compiles the source code and generate byte code. Saved in the
.class file.
Step 2 : The JVM/Interpreter generates output by executing byte code.
Blue j
Is a free java environment (user interface) developed by Monash University,
Australia. It is an editor which allows to write, edit and run java program. Other
environments are eclipse, NetBeans etc.
7
NASIR UMER
COMPUTER APPLICATIONS
Features of blue j
GUI
Easy to use
Editor, debugger, and output terminal
Data types
Type of literals(constant) and the amount of space to be allocated is called dt.
Divided into two types.
A) Primitive: byte, short, int, long, float, double, char, boolean
Data type bytes intital(default) values
byte 1/8bits 0
short 2/16bits 0
int 4/32bits 0
long 8/64bits 0l/0L
float 4 0.0f/0.0F
double 8 0.0d/0.0D
char 2 ‘\u0000’
boolean 1 false
B) Non-primitive(reference)/composite/UDT-User Defined Data Type
class, array, String and interface
Non primitive type are called reference data types.
Based on fundamental(primitive) data types.
*************************************************************