Java Fundamentals

Java Introduction, History, OOP, Features, JDK, Tokens, Keywords, Operators & Statements

Prepared by Srikanth Mamillapalli

1. Java History

Key Facts

  • Father of Java: James Gosling
  • Java introduced at: Sun Microsystems
  • Java was originally called: Oak
  • First public implementation: Java 1.0 in 1995
  • Core principle: Write Once, Run Anywhere (WORA)

The source notes describe Java as an object-oriented programming language with a runtime environment. It combines features associated with C and C++ with additional concepts and is suitable for standalone as well as web application development.

2. What is Java?

  • Java is an object-oriented programming language developed by Sun Microsystems and released in 1995.
  • James Gosling initially developed Java at Sun Microsystems, which was later merged with Oracle Corporation.
  • Java is described in the source as having its format from C and OOP features from C++.
  • Java programs are platform independent: the same compiled program can run on different operating systems when the appropriate Java runtime is available.
  • The ability to write code once and run it on different platforms is commonly summarized as WORA — Write Once, Run Anywhere.

3. Object-Oriented Paradigm

The primary objective of the object-oriented technique is to eliminate some flaws encountered in the procedural approach.

OOP treats data as a critical element and uses objects and methods to organize and protect that data.

Object: The source illustration represents an object as containing data and methods, with methods surrounding/operating on the data.

4. Major Objectives of Object-Oriented Programming

  • The emphasis is on the data rather than the procedures.
  • Methods that operate on data are tied together in a data structure.
  • Programs are divided into small instances called objects.
  • Data remains hidden and cannot be accessed directly by external functions.
  • Objects may communicate with each other through methods.
  • Programs follow the bottom-up approach.
  • New data and methods can be added whenever necessary.

5. Basic Terms and Features of OOP

Classes & Objects

Represent the structure and instances of an object-oriented program.

Data Abstraction

Expose essential behavior while hiding implementation details.

Data Encapsulation

Wrap data and the methods that operate on it together.

Inheritance

Allows a class to acquire features from another class.

Polymorphism

Allows one interface or operation to have multiple forms.

Dynamic Binding

Connects an overridden method call with its implementation at runtime.

Composition

Builds complex objects by combining other objects.

6. Advantages of OOP

  • Code recycle and reuse.
  • Wrapping up of data into a single unit.
  • Easy to partition project work based on objects.
  • Message passing between objects makes interface descriptions with external systems more straightforward.
  • Software complexity can be handled and managed more easily.
  • Objects in a problem domain can be mapped into a program.
  • Data hiding is possible.
  • Inheritance can eliminate redundant code.

7. Java Features

FeatureDescription
Platform IndependentThe same .class bytecode can work on different operating systems with a suitable Java runtime.
SimpleThe source describes Java as small and familiar to C and C++ programmers.
Object OrientedFocuses on data and the interface to it through objects.
DistributedSupports applications that operate across networked systems.
PortableJava programs are designed to move between platforms with minimal platform-specific changes.
InterpretedJava bytecode is executed by the Java runtime.
High PerformanceJIT (Just-In-Time) compilation improves runtime performance.
MultithreadedSupports execution of multiple threads.
DynamicJava supports dynamic loading and runtime linking concepts.

8. Types of Java Applications

1. Standalone Applications

A Java application designed without a client-server architecture is called a standalone application.

2. Distributed Applications

A Java application designed on the basis of a client-server architecture is called a distributed application.

The source notes associate distributed application development with the J2EE / Java EE platform.

9. Java Details

ItemDetails from the Source
Home / VendorSun Microsystems (later Oracle Corporation)
AuthorJames Gosling
ObjectiveTo prepare simple electronic consumer goods
ProjectGreen
First VersionJDK 1.0 (January 23, 1996)
TypeOpen Source Software, as stated in the source notes
The PDF contains version references that are historical/course-note specific. The table preserves the information as presented in the source.

10. Java Introduction Details

Java introduction details and Core Java technologies diagram

The source's Java introduction page identifies James Gosling as author, Sun Microsystems as vendor, Green Project as the project name, Oak as the initial name, Java as the present name, and WORA as the slogan/motto.

ItemSource Information
AuthorJames Gosling
VendorSun Micro System (later merged into Oracle Corporation)
Project NameGreen Project
TypeOpen source & free software
Initial NameOAK language
Present NameJava
Extensions.java, .class & .jar
Initial VersionJDK 1.0
Present Version in SourceJ2SE 8 / 2014
Operating SystemMulti Operating System
Implementation LanguageC, C++
ObjectiveTo develop web applications
SUNStanford University Network
Slogan / MottoWORA — Write Once, Run Anywhere

11. Importance of Core Java

According to the source notes, Java is used in a wide range of applications and technologies.

  1. Desktop applications such as media players and antivirus applications.
  2. Web applications.
  3. Enterprise applications such as banking applications.
  4. Mobile applications.
  5. Embedded systems.
  6. SmartCards.
  7. Robotics.
  8. Games.

Core Java Ecosystem Mentioned in the Source

Webservices, Hadoop, Selenium, Android, Cloud Computing, ADF, EJBs, Spring, Hibernate and Struts are shown around Core Java in the source diagram.

12. Parts of Java

The source states that, according to Sun Microsystems, the Java language/platform is divided into three parts:

PartFull Form
J2SE / JSEJava 2 Standard Edition
J2EE / JEEJava 2 Enterprise Edition
J2ME / JMEJava 2 Micro Edition

13. JDK Includes

ToolPurpose
javacJava Compiler
javaJava Interpreter / launcher
javapJava Disassembler
javahUsed for C-language header files in the source notes
javadocCreates HTML documentation
jdbJava Debugger

14. Java Program Start to END Flow

Java program flow chart from source PDF

The source flow chart shows the basic path:

Text Editor
Java Source Code
javac
Java Class File
Java
Output

The diagram also shows javah leading to header files and the Java class file leading to the debugger path.

15. Tokens

The smallest logical unit in Java programming is called a lexeme. A collection of lexemes belonging to a particular group is called a token.

Example

int a = b + c * d;

Lexemes: int, a, =, b, +, c, *, d, ;

Types of Tokens

Identifiers

Names assigned to programming elements.

Literals

Constant values assigned or used in programs.

Keywords / Reserved Words

Predefined words recognized by Java.

Operators

Symbols that perform operations on operands.

16. Identifiers

An identifier is a name assigned to programming elements such as variables, methods, classes, abstract classes and interfaces.

int a = 10;
ElementMeaning
intData type
aVariable / identifier
=Operator
10Constant / literal
;Terminator

17. Literals

A literal is a constant value represented directly in a Java program.

Literal TypeExamples
Integer / Integralbyte, short, int, long → 10, 20, 30...
Character'A', 'B'...
Floating Pointfloat → 10.22f; double → 11.123
Booleantrue, false
String"abc", "def"...

18. Number Systems in Java

Programming languages use number systems to represent numbers. The source lists four common number systems.

Binary

Base 2

Octal

Base 8

Decimal

Base 10

Hexadecimal

Base 16

19. Keywords / Reserved Words

The source defines a keyword as a predefined word having recognition and internal functionality. It also distinguishes reserved words as predefined words reserved by the language.

Examples mentioned: goto, const.

Keyword Categories

CategoryExamples
Data Types / Return Typesbyte, short, int, long, float, double, char, boolean, void
Access / Other Modifierspublic, protected, private, static, final, abstract, native, volatile, transient, synchronized, strictfp
Flow Controllersif, else, switch, case, default, for, while, do, break, continue, return
Class / Object Relatedclass, enum, extends, interface, implements, package, import, new, this, super
Exception Handlingthrow, throws, try, catch, finally

20. Operators

An operator is a symbol that performs a particular operation over the provided operands.

Operator TypeOperators
Arithmetic+ - * / % ++ --
Assignment= += -= *= /= %=
Comparison== != < > <= >=
Boolean / Logical& | ^
Bitwise / Shift& | ^ << >>
Short-Circuit&& ||
TernaryExpr1 ? Expr2 : Expr3

21. Java Comments

Single-Line Comment

Starts with two forward slashes.

// This is a comment

Multi-Line Comment

Starts with /* and ends with */.

/*
 * This is a
 * multi-line comment
 */

Documentation Comment

The source gives the following author documentation format.

/**
 * @author smamilla
 */

22. Java Statements

A statement is a collection of expressions. Java statements are instructions that tell the programming language what to do.

Examples

double entryFee = 15.75;
int a = 12;

Different Types of Statements

  • General Purpose Statements
  • Declaring variables, methods and classes
  • Creating objects and accessing variables and methods
  • Conditional statements
  • Iterative statements
  • Transfer statements
  • Exception handling statements
  • Synchronized statements

23. Quick Revision

TopicKey Point
Father of JavaJames Gosling
Original NameOak
First Public JavaJava 1.0 in 1995
WORAWrite Once, Run Anywhere
OOPUses objects, data and methods to structure programs.
OOP FeaturesClasses & Objects, Abstraction, Encapsulation, Inheritance, Polymorphism, Dynamic Binding, Composition.
Java FeaturesPlatform independent, simple, object-oriented, distributed, portable, interpreted, high performance, multithreaded and dynamic.
Application TypesStandalone and distributed applications.
JDK Toolsjavac, java, javap, javah, javadoc, jdb.
TokensIdentifiers, literals, keywords/reserved words and operators.
Number SystemsBinary, Octal, Decimal and Hexadecimal.
CommentsSingle-line, multi-line and documentation comments.
StatementsInstructions such as declarations, conditionals, loops, transfers, exception handling and synchronization.