[Go to site: main page, start]

0% found this document useful (0 votes)
8 views8 pages

Java Programming Concepts and Features

The document provides an overview of Java programming, including its definition, features, and object-oriented concepts such as classes, objects, encapsulation, abstraction, polymorphism, and inheritance. It explains the Java compilation process, the role of the Java Development Kit (JDK), and the use of BlueJ as a Java environment. Additionally, it outlines data types in Java, distinguishing between primitive and non-primitive types.

Uploaded by

niyati
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views8 pages

Java Programming Concepts and Features

The document provides an overview of Java programming, including its definition, features, and object-oriented concepts such as classes, objects, encapsulation, abstraction, polymorphism, and inheritance. It explains the Java compilation process, the role of the Java Development Kit (JDK), and the use of BlueJ as a Java environment. Additionally, it outlines data types in Java, distinguishing between primitive and non-primitive types.

Uploaded by

niyati
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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
[Link] (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.

*************************************************************

Common questions

Powered by AI

Inheritance in Java allows a new class to inherit properties and methods from an existing class, facilitating code reusability and extension. This is implemented using the 'extends' keyword, where a derived/child/sub class inherits from a base/parent/super class. This enables the derived class to use and override functionalities of the base class, promoting the extendable software design .

The Java Development Kit (JDK) is a comprehensive software development environment crucial for developing Java applications and applets. It includes the Java Runtime Environment (JRE), which is necessary to run Java programs. The JRE consists of the Java Virtual Machine (JVM) and library classes that provide the necessary environment to execute Java applications, while the additional tools in the JDK assist in the software development process .

Java’s platform-independence has significantly impacted modern software deployment by simplifying the distribution of applications across varied platforms. Developers can write code once and deploy it anywhere, eliminating the complexity of platform-specific adaptations. This has led to decreased development time, reduced costs, and greater flexibility in reaching a wider audience, ultimately benefiting cloud-based and distributed application models .

In Java, data types are classified into two main categories: primitive and non-primitive (reference) types. Primitive types include byte, short, int, long, float, double, char, and boolean, providing basic data operations and storing simple values. Non-primitive types, such as classes, arrays, and interfaces, are based on these primitive types and allow for the creation of complex data structures essential for object manipulation in Java programming .

Java's runtime environment is distinguished by its use of byte code, an intermediate platform-independent code. Unlike traditionally compiled languages that convert source code directly into machine-specific code, Java compiles to byte code, which is executed by the Java Virtual Machine (JVM). This abstraction layer allows Java programs to run on any device with a compatible JVM, offering significant flexibility and platform independence .

Encapsulation enhances security by wrapping data and methods within a single unit (often a class) and restricting direct access to some components, thus protecting data integrity. Abstraction, on the other hand, allows developers to focus on essential features and hide background details, simplifying management by reducing complexity and enabling modular design. These principles together help developers build secure and manageable applications by controlling data visibility and simplifying interaction interfaces .

In object-oriented programming (OOP) within Java, objects are defined by their attributes and methods, which form the core of OOP concepts. Attributes represent the object's properties, while methods define the object's behaviors. This encapsulation of data and behaviors allows objects to model real-world entities more accurately, enabling developers to construct reusable and maintainable code .

Java is a popular programming language due to features like being an OOP language, using both a compiler and an interpreter, and being platform-independent. Its WORA (write once, run anywhere) capability allows Java to operate across different operating systems without modification. The byte code compiled from Java is platform-independent, meaning it can run on any machine with a JVM (Java Virtual Machine) which processes the byte code into machine code, ensuring uniformity across platforms .

Polymorphic behavior in Java, achieved through function overloading, allows multiple methods with the same name but different parameters to exist within a class. This enables software flexibility by allowing method calls to be determined at runtime based on the argument list. It enhances code readability and maintainability by allowing developers to use a single method name to perform different tasks based on input parameters .

Java uses both a compiler and an interpreter, which impacts error handling and debugging. The compiler translates the entire source code into byte code, identifying errors before runtime, which allows developers to address these compile-time errors early in the development process. The interpreter, during execution, translates byte code into machine code line-by-line and halts on errors, enabling developers to handle runtime errors effectively as they occur. This dual approach aids thorough error detection and efficient debugging .

You might also like