Java - Lect1
Java - Lect1
Disadvantage:
Procedural Programming :
There is no difference in between procedural and imperative approach. It has the ability to
reuse the code and it was boon at that time when it was in use because of its reusability.
Advantages:
• Data security
• Inheritance
• Code reusability
• Flexible and abstraction is also present
Parallel processing approach –
• Examples are NESL (one of the oldest one) and C/C++ also supports
because of some library function.
Declarative programming paradigm:
Java platform.
proprietary licenses
• There are four platforms of the Java programming language:
1. Java Platform, Standard Edition (Java SE): defines everything
- basic types
- objects to high-level classes for
- networking, security, database access, graphical user interface (GUI) development,
and XML parsing.
2. Java Platform, Enterprise Edition (Java EE): It is on top of Java SE. It provides API and runtime
environment for developing and running large-scale, multi-tiered, scalable, reliable, and secure
network applications.
3. Java Platform, Micro Edition (Java ME):provides an API and a small-footprint virtual machine
for running Java programming language applications on small devices, like mobile phones.
4. JavaFX: is a platform for creating rich internet applications using a lightweight user-interface
API.
Features of Java
1. Java is both compiled and interpreted language: Java compiler translates
source code into bytecode instructions. Bytecode are not machine
instructions so in second stage , Java interpreter generates machine code
that can be directly executed by the machine running the java program.
2. Platform independent and portable: java compiler generates bytecode
instructions implemented on any machine. Also, the size of the primitive data
types are machine-independent.
3. Object –oriented: everything in Java is an object. All program code and data
reside within objects and classes.
4. Robust and Secure: Java ensures reliable code. Because
- garbage collected language: The garbage collector finds these unused
objects and deletes them to free up memory. (automatic memory management).
-handles memory management mistakes.
-Exception handling : captures series of errors and eliminates risk of crashing
the system.
- Strict compile time and run-time checking for data types.
- Absence of pointers ensures not to have direct access to memory
locations.
1. Reserved Keywords
2. Identifiers
3. Literals
4. Operators
5. Separators
Keywords and Identifiers
• Java is case sensitive so we can use these words as identifiers by changing letters
to upper case.
• Identifiers: these are programmer-designed tokens. They are used for naming
classes, methods, variables , objects, labels, packages and interfaces .
• Rules:
1. Identifiers can have digits, alphabets underscore and dollar sign.
2. Not begin with a digit
3. Case sensitive
4. Any length
1. Names of public methods and instance variables start with lowercase
letter.
Eg: average, sum
2. If more than one words in name then,
dayTemp, firstDayOfMonth, totalMarks
3. All private and local variables can start with lowercase combined with
underscore.
length, class_strength
4. All classes and interfaces start with leading upper class letter
Student, HelloJava, Vehicle
5. Symbolic constants : variables having constant values use all uppercase
letters and underscore.
TOTAL, F_MAX
Literals : represent constant values stored in variables .
Integer literals, Floating point literals, character literals, String literals
and Boolean Literals
Separators:
(), { }, [ ], ; , .
, used to separate variables.
. Used to separate package names from sub-packages and classes
Java Control Statements
1. Selection: if , if –else, switch