2.fundamentals of Java
2.fundamentals of Java
Adeniyi A.E.
2: Fundamentals of Java PL
2. Fundamentals of Java PL
•By the end of this topic, you will be able to:
i. understand the Java programming platform
ii.describe the fundamentals of Java
iii.develop programs using Java
2. Fundamentals of Java PL
•What is Java:
• It is a programming language and a computing platform
• Java is a general-purpose, multi-platform, object-oriented, and network-centric
programming language.
•Features of Java
• Easy-to-use PL
• Write once run many times i.e., platform-independent
• It is a multithreaded language
• It provides memory management capability – has garbage collector
• It is network-centric, provides distributed computing features
2. Fundamentals of Java PL
•History of Java:
• It was developed by James Gosling in Sun Microsystem
• The name was changed to Java in 1995 due to trademark issue and
modified it to take advantage of the emerging www.
• Example:
int x;
double y = 11.5;
private float z = 3.5f;
• Variables of the same data types and access modifier can be declared using a single line
statement. E.g.:
double p, q, r;
2. Fundamentals of Java PL
• Constant
• A constant is an entity whose value cannot be changed or altered during the course of
program execution
• In Java, a constant is declared using the keyword: final
• Example:
final double PI = 3.14159;
• Keywords/Reserved words:
• They are words with re-defined meaning and can only be used for the purposes for which they
are defined.
• Java keywords:
abstrtact, assert, Boolean, break, byte, case, catch, char, class, const,
continue, default, do, double, else, enum, extends, final, finally, float,
for, goto, if, implements, import, instanceof, int, interface, long, native,
new, package, private, protected, public, return, short, static, strictfp,
super, switch, synchronise, this, throw, throws, transient, try, void,
volatile, while
2. Fundamentals of Java PL
• Identifier:
• Identifiers are the symbolic names given to program entities
• Rules and conventions for specifying Identifiers in Java:
• Only alphanumeric characters ([a-z] [A-Z] [0-9]), $ and _ are allowed in
identifiers
• Must not start with number
• Must not contain whitespace
• They are case sensitive e.g.: total, Total, toTal, totaL are 4 different
identifiers
• Reserved keywords cannot be used as identifiers
• Example:
Valid identifiers: NomansLand90, $Wink1NTomBoy, Four_HorseMen$2021,
_AngryMonk404, final_result_value, Employee, EMP12
Invalid identifiers: wiseWizard#1994, 3000Buckets, @Employee,
Four HorseMen$2021, 36-StudentPro9,
final result value
2. Fundamentals of Java PL
• Identifier:
• Identifiers are the symbolic names given to program entities
• Conventions for specifying Identifiers in Java:
• Identifiers for constants should be in UPPER CASE
• Class names should be in Sentence case
• Identifiers with multiple words should use the camel case
• Objects and variables should be in lower case
2. Fundamentals of Java PL
• Data Types: