Assessment1_SadipNeupane
Assessment1_SadipNeupane
2. History of Java
• Origins: Java was developed by Sun Microsystems in the early 1990s. The project was
initiated by a small team known as the Green Team, led by James Gosling.
• Initial Purpose: Originally designed for interactive television, Java was too advanced for
the digital cable television industry at the time.
Name Evolution:
• Initially called "Greentalk" then renamed "Oak" after the oak tree, a symbol of
strength.
• Finally renamed "Java" in 1995 due to trademark issues with Oak Technologies.
The name was inspired by Java coffee, which the team enjoyed.
• Release: Java was officially released in 1995 and quickly gained popularity, especially for
web development. (Anon., n.d.)
1
3. Principles of Java
Java was designed with several core principles in mind:
• Simple: Java's syntax is easy to learn and understand, making it accessible for beginners.
• Robust: Java emphasizes strong memory management and error handling, reducing the
likelihood of crashes.
• Portable: Java programs can run on any device with a JVM, making it highly portable.
• Platform-Independent: The "Write Once, Run Anywhere" (WORA) philosophy allows
Java applications to be executed on any platform without modification.
• Secure: Java provides a secure environment through its classloader and bytecode
verifier, which help prevent unauthorized access and code execution.
• High Performance: Java uses Just-In-Time (JIT) compilation to improve performance by
converting bytecode into native machine code at runtime.
• Multithreaded: Java supports multithreading, allowing multiple threads to run
concurrently, which is essential for modern applications.
• Architecture Neutral: Java bytecode is not tied to any specific hardware architecture.
• Object-Oriented: Java is built around the concept of objects, which encapsulate data
and behavior.
• Interpreted: Java code is compiled into bytecode, which is interpreted by the JVM.
• Dynamic: Java can adapt to changing environments, allowing for dynamic loading of
classes and methods. (Anon., n.d.)
4. Versions of Java
Java has evolved through several major versions, each introducing new features and
improvements:
• Java 1.0 (1996): The first official release, which included basic features for applets and
GUI applications.
• Java 2 (1998): Introduced the Swing GUI toolkit and the Collections Framework.
• Java 5 (2004): Added generics, annotations, enumerated types, and the enhanced for
loop.
2
• Java 8 (2014): Introduced lambda expressions, the Stream API, and the new Date and
Time API.
• Java 11 (2018): A Long-Term Support (LTS) version that included new features like the
HTTP Client API and local-variable syntax for lambda parameters.
• Java 17 (2021): The latest LTS version, which includes features like sealed classes and
pattern matching for switch expressions.
5. Editions of Java
Java is available in several editions, each tailored for different types of applications:
• Java Standard Edition (SE): The core Java platform for general-purpose programming,
including libraries for GUI development, networking, and data structures.
• Java Enterprise Edition (EE): A set of specifications that extend Java SE with features for
building large-scale, distributed applications, including servlets, JSP, and EJB.
• Java Micro Edition (ME): A subset of Java SE designed for mobile and embedded
devices, providing a lightweight environment for applications.
6. Environment of Java
The Java environment consists of several key components:
• Java Development Kit (JDK): A software development kit that includes tools for
developing Java applications, such as the Java compiler (javac), the Java Runtime
Environment (JRE), and various utilities.
• Java Runtime Environment (JRE): Provides the libraries and components necessary to
3
7. Download, Installation, and Configuration of JDK
• Download: Visit the Oracle JDK download page or use OpenJDK.
• Installation:
Windows: Run the installer and follow the prompts.
macOS: Use the .dmg file to install.
Linux: Use package managers like apt or yum to install.
• Configuration:
• Set the JAVA_HOME environment variable to point to the JDK installation directory.
• Add the bin directory of the JDK to the PATH variable to run Java commands from the
command line.
4
9. Hello World of Java
5
11. Project Management in Eclipse
• Open Eclipse and select File > New > Java Project.
• Enter the project name
• Click Finish to create the project.
6
14. Character Set of Java
• The uppercase letters 'A' through 'Z'
• The lowercase letters 'a' through 'z'
• The digits '0' through '9'
• The dash character '-'
• The plus character '+'
• The period character '.'
• The colon character ':'
• The underscore character '_'
7
16. Identifiers
• All Java variables must be identified with unique names. These unique names are
called identifiers.
• Identifiers can be short names (like x and y) or more descriptive names (age, sum,
totalVolume). It is preferred to have a descriptive name.
There are some soft rules for identifiers. Some are listed below:
Exercise
Which is NOT a legal variable name?
A.int myInteger = 20;
B.int int = 20;
C.int myNum = 20;
D.int num = 20;
8
17. Data Types
• Reference types include objects and arrays.
• They store references to the actual data rather than the data itself.
Data types include:
1. Numeric
byte bn;
short sn;
int in;
long ln;
loat fn;
double dn;
2. Non-Numeric
boolean res; //true|false
char ch; //single quote character
string strl; //Double quote character
objects obj1; //all of above
9
18. Operators, Precedence, and Associativity
Operator, Precedence and Associativity defines which operator should be taken into account
first. It is similar to the BODMAS rule we have learned in our school mathematics.
A Java operator is a special symbol that performs a certain operation on multiple operands and
gives the result as an output.
Operators can be classified as following:
-Arithmetic
- relational
- logical
-bitwise operators
Operator Precedence
Operator precedence defines the priority of operators in an expression.
For example, in the expression 3 + 4 * 5,
the multiplication operator (*) has higher precedence than the addition operator (+), so the
multiplication is performed first, resulting in 3 + 20, which equals 23.
Operator Associativity
Associativity determines the order of evaluation for operators of the same precedence level. It
can be either left-to-right or right-to-left:
• Left-to-Right: Most operators (like +, -, *, /, and &) are left associative, meaning they are
evaluated from left to right. For example, in the expression 10 - 5 + 2, it is evaluated
as (10 - 5) + 2, resulting in 7.
• Right-to-Left: Some operators (like the assignment operator = and the ternary
conditional operator ? :) are right associative. For example, in the expression a = b = 5, it
is evaluated as a = (b = 5).
(Anon., n.d.)
10
19. Expression and Statements
• A Java expression consists of variables, operators, literals, and method calls.
(Anon., n.d.)
11
20. Comments
comments are used to explain the code, which makes it easier to understand for anyone reading
it, including the original author.
Example
(Anon., n.d.)
12
Works Cited
Anon., n.d. [Online]
Available at: https://www.programiz.com/java-programming/expressions-statements-blocks
[Accessed 19 01 2025].
Michael T., Roberto T., Michael H, 2014. In: Data Structures and Algorithms in Java. s.l.:Wiley Press.
Paul D, Harvey D, (2012) Java How to Program. 9th edn. Newyork USA: Pearson
13