[Go to site: main page, start]

0% found this document useful (0 votes)
4 views31 pages

Module 1 - Core Java

The document provides an introduction to Java programming, covering its history, features, and fundamental concepts such as object-oriented programming, data types, and control statements. It explains the significance of Java's platform independence through the Java Virtual Machine (JVM) and the Java Development Kit (JDK). Additionally, it outlines key programming constructs including operators, arrays, and command-line arguments.
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)
4 views31 pages

Module 1 - Core Java

The document provides an introduction to Java programming, covering its history, features, and fundamental concepts such as object-oriented programming, data types, and control statements. It explains the significance of Java's platform independence through the Java Virtual Machine (JVM) and the Java Development Kit (JDK). Additionally, it outlines key programming constructs including operators, arrays, and command-line arguments.
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

CORE JAVA -

CSIT751

Mr Sumin Sybol
Visiting Faculty,
Amity Institute of Information Technology
Amity University, Noida
MODULE 1 –
INTRODUCTION TO JAVA PROGRAMMING

• Introduction to Java, OOPS concepts, Java features;


• Data Types, Variables, identifiers, Arrays, Operators, and Control Statements;
• Command line arguments;
INTRODUCTION TO JAVA

• Java: Object-oriented, class-based language.


• Aim for minimal implementation dependencies.
• "Write Once, Run Anywhere" (WORA) principle.
• Java bytecode executed by the Java Virtual Machine (JVM) ensures platform
independence.
• First released in 1995; used in desktop, web, and mobile app development.
• Valued for simplicity, robustness, and security features.
• Trusted for enterprise-level applications.
HISTORY OF JAVA

• Java history is interesting to know. The history of java starts from Green Team. Java team
members (also known as Green Team), initiated a revolutionary task to develop a language
for digital devices such as set-top boxes, televisions, etc.

• For the green team members, it was an advance concept at that time. But, it was suited for
internet programming. Later, Java technology as incorporated by Netscape.

• Currently, Java is used in internet programming, mobile devices, games, e-business


solutions etc. There are given the major points that describe the history of java.
HISTORY OF JAVA

1) James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June
1991. The small team of sun engineers is called Green Team.
2) Originally designed for small, embedded systems in electronic appliances like set-top boxes.
3) Firstly, it was called “Greentalk” by James Gosling, and file extension was .gt.
4) After that, it was called Oak and was developed as a part of the Green project.

Why is Oak name for Java language?


5) Why Oak? Oak is a symbol of strength and is chosen as a national tree of many countries like the
U.S.A., France, Germany, Romania etc.
6) In 1995, Oak was renamed "Java" because it was already a trademark by Oak Technologies.
HISTORY OF JAVA

Why Java name for java language?

7) Why they choosed java name for java language? The team gathered to choose a new name. The suggested
words were "dynamic", "revolutionary", "Silk", "jolt", "DNA" etc. They wanted something that reflected the essence
of the technology: revolutionary, dynamic, lively, cool, unique, and easy to spell and fun to say.

According to James Gosling "Java was one of the top choices along with Silk". Since java was so unique, most of
the team members preferred java.

8) Java is an island of Indonesia where first coffee was produced (called java coffee).

9) Notice that Java is just a name not an acronym.

10) Originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation)
and released in 1995.

11) In 1995, Time magazine called Java one of the Ten Best Products of 1995.

12) JDK 1.0 released in(January 23, 1996).


OOPS (OBJECT-ORIENTED PROGRAMMING
SYSTEM)

Object means a real-world entity such as a pen, chair, table, computer, watch, etc. Object-Oriented
Programming is a methodology or paradigm to design a program using classes and objects. It simplifies
software development and maintenance by providing some concepts:

• Object - Any entity that has a state and behaviour.

• Class - Collection of objects.

• Inheritance - When one object acquires all the properties and behaviours of a parent object.

• Polymorphism - one task is performed in different ways, i.e method overloading and method
overriding.

• Abstraction - Hiding internal details and showing functionality, i.e Abstract Class.

• Encapsulation - Binding (or wrapping) code and data together into a single unit.
OOPS (OBJECT-ORIENTED PROGRAMMING
SYSTEM)
FEATURES OF JAVA

• Simple
• Object-Oriented
• Portable
• Platform independent
• Secured
• Robust
• Architecture neutral
• Interpreted
• High Performance
• Multithreaded
• Distributed
• Dynamic

Reference: [Link]
JDK
JDK: JAVA DEVELOPMENT KIT

• JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a
software development environment that is used to develop Java applications and applets. It
physically exists. It contains JRE + development tools.

• JDK is an implementation of any one of the below given Java Platforms released by Oracle
corporation:
• Standard Edition Java Platform
• Enterprise Edition Java Platform
• Micro Edition Java Platform

• The JDK contains a private Java Virtual Machine (JVM) and a few other resources such as
an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation
generator (Javadoc) etc. to complete the development of a Java Application.
JVM

• JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides


runtime environment in which java bytecode can be executed.
• JVMs are available for many hardware and software platforms (i.e. JVM is platform
dependent).

• A specification where working of Java Virtual Machine is specified. But implementation


provider is independent to choose the algorithm. Its implementation has been provided by
Oracle and other companies.
• An implementation Its implementation is known as JRE (Java Runtime Environment).
• Runtime Instance Whenever you write java command on the command prompt to run the
java class, an instance of JVM is created.
BYTE CODE

• Byte Code can be defined as an intermediate code generated by


the compiler after the compilation of source code(JAVA Program).
• This intermediate code makes Java a platform-independent
language.

How is Byte Code generated?


• The compiler converts the source code or the Java program into
the Byte Code(or machine code), and secondly, the Interpreter
executes the byte code on the system.
• The Interpreter can also be called JVM(Java Virtual Machine).
The byte code is the common piece between the compiler(which
creates it) and the Interpreter (which runs it).
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).
• Note: It is recommended to use descriptive names in order to create understandable and
maintainable code:

// Good
int minutesPerHour = 60;
// OK, but not so easy to understand what m actually is
int m = 60;
DATA TYPES

Data types are divided into two groups:

• Primitive data types - include byte, short, int, long, float, double, boolean and char
• Non-primitive data types - such as String, Arrays and Classes

int myNum = 5; // Integer (whole number)


float myFloatNum = 5.99f; // Floating point number
char myLetter = 'D'; // Character
boolean myBool = true; // Boolean
String myText = "Hello"; // String
PRIMITIVE DATA TYPES
OPERATORS

Java divides the operators into the following groups:

• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Bitwise operators
ARITHMETIC OPERATORS
ASSIGNMENT OPERATORS
COMPARISON OPERATORS
LOGICAL OPERATORS
Control Statements

Decision Making statements


• if statements
• switch statement

Loop statements
• for loop
• do while loop
• while loop

Jump statements
• break statement
• continue statement
IF STATEMENT

if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
SWITCH STATEMENT

switch(expression) {
case x:
// code block
break;
case y:
// code block
break;
default:
// code block
}
FOR LOOP STATEMENT

for (statement 1; statement 2; statement 3) {


// code block to be executed
}

for (int i = 0; i < 5; i++) {


[Link](i);
}
WHILE STATEMENT

while (condition) {
// code block to be executed
}

int i = 0;
while (i < 5) {
[Link](i);
i++;
}
DO WHILE STATEMENT

do {
// code block to be executed
}
while (condition);

int i = 0;
do {
[Link](i);
i++;
}
while (i < 5);
BREAK STATEMENT

for (int i = 0; i < 10; i++) {


if (i == 4) {
break;
}
[Link](i);
}
CONTINUE STATEMENT

for (int i = 0; i < 10; i++) {


if (i == 4) {
continue;
}
[Link](i);
}
ARRAYS STATEMENT

Arrays are used to store multiple values in a single variable, instead of declaring separate
variables for each value.

String[] cars;
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
int[] myNum = {10, 20, 30, 40};
[Link](cars[0]);

cars[0] = "Opel";
[Link]([Link]);
COMMAND LINE ARGUMENTS

• Java command-line argument is an argument i.e. passed at the time of running the Java program.
• In Java, the command line arguments passed from the console can be received in the Java
program, and they can be used as input.
• The users can pass the arguments during the execution, by passing the command-line arguments
inside the main() method.

class GFG {
public static void main(String[] args)
{
[Link](args[0]);
}
}

You might also like