0% found this document useful (0 votes)
15 views70 pages

Java-Day1 by Bunny

The document provides an introduction to the Java programming language. It discusses various Java buzzwords like simple, object-oriented, platform independent, secured, robust, architecture neutral, portable, high-performance, distributed, multi-threaded, dynamic. It also describes Java Development Kit, Java Runtime Environment and Java Virtual Machine.

Uploaded by

panetirahul
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)
15 views70 pages

Java-Day1 by Bunny

The document provides an introduction to the Java programming language. It discusses various Java buzzwords like simple, object-oriented, platform independent, secured, robust, architecture neutral, portable, high-performance, distributed, multi-threaded, dynamic. It also describes Java Development Kit, Java Runtime Environment and Java Virtual Machine.

Uploaded by

panetirahul
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
You are on page 1/ 70

Introduction To JAVA

Mrs. Soniya Sharma [email protected]


Java is Everywhere

Mrs. Soniya Sharma [email protected]


Java Buzzwords

Mrs. Soniya Sharma [email protected]


Java Buzzwords

• Simple:

Java language is a simple programming language because:

• Java syntax is based on C++ (so easier for programmers to learn it after C++).

• Java has removed many complicated and rarely-used features, for example,
explicit pointers, operator overloading, etc.

• There is no need to remove unreferenced objects because there is an


Automatic Garbage Collection in Java.

Mrs. Soniya Sharma [email protected]


Java Buzzwords

• Object Oriented
Object-oriented programming (OOPs) is a methodology that simplifies software
development and maintenance by providing some rules.
• Basic concepts of OOPs are:
• Object
• Class
• Inheritance
• Polymorphism
• Abstraction
• Encapsulation

NOTE - OOP Features will be discussed in detail in next sprints.


Mrs. Soniya Sharma [email protected]
Java Buzzwords

• Platform Independent

Java code can be executed on multiple platforms, for


example, Windows, Linux, Sun Solaris, Mac/OS, etc. Java
code is compiled by the compiler and converted into
bytecode.

This bytecode is a platform-independent code because it can


be run on multiple platforms, i.e., Write Once and Run
Anywhere (WORA).

Mrs. Soniya Sharma [email protected]


Java Buzzwords

• Secured

Java is best known for its security. With Java, we can develop virus-free systems.
Java is secured because:

• No explicit pointer
• Java Programs run inside a virtual machine sandbox

Mrs. Soniya Sharma [email protected]


Java Buzzwords

• Robust

Java is robust because:

• It uses strong memory management.


• There is a lack of pointers that avoids security problems.
• Automatic garbage collection process by sporadically executing finalize().
• Exception handling and the type checking mechanism.

Mrs. Soniya Sharma [email protected]


Java Buzzwords

• Architecture Neutral
There are no implementation dependent features.

• For example, the size of primitive types is fixed.

• In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and
4 bytes of memory for 64-bit architecture. In java it occupies 4 bytes of memory for both
32 and 64-bit architectures in Java.

Mrs. Soniya Sharma [email protected]


Java Buzzwords

• Portable
• Java is portable because it facilitates you to carry the Java bytecode to any platform. It
doesn't require any implementation.

• High-performance
• The Java bytecode was carefully designed so that it would be easy to translate directly
into native machine code for very high performance by using a just-in-time compiler.

Mrs. Soniya Sharma [email protected]


Java Buzzwords

• Distributed

• Java is designed for the distributed environment of the Internet, because it handles
TCP/IP protocols. RMI and EJB are used for creating distributed applications. This
feature of Java makes us able to access files by calling the methods from any machine
on the internet.

Mrs. Soniya Sharma [email protected]


Java Buzzwords
• Multi-threaded

• A thread is like a separate program, executing concurrently. We can write Java


programs that deal with many tasks at once by defining multiple threads. The main
advantage of multi-threading is that it doesn't occupy memory for each thread. It shares
a common memory area. Threads are important for multi-media, Web applications, etc.

• Dynamic

• Java programs carry with them substantial amounts of run-time type information that is
used to verify and resolve accesses to objects at run time. This makes it possible to
dynamically link code in a safeMrs.and
Soniyaexpedient manner.
Sharma [email protected]
Java’s Magic : Bytecode
• The output of Java compiler is not executable code rather, it is bytecode.

• Bytecode allows Java to solve both the security and the portability problems.

• Bytecode is executed by the Java run-time system, which is called as Java Virtual
Machine (JVM).

• The JVM is an interpreter for bytecode.

• Bytecode makes it possible to run a program in a wide variety of environments as only


the JVM needs to be implemented for each platform.

• The Just In Time compiler, compiles the code as needed, during execution, this gives
significant performance boost.
Mrs. Soniya Sharma [email protected]
Java’s Magic : Bytecode

Mrs. Soniya Sharma [email protected]


Java Development Kit (JDK)

JDK helps the programmer in


development(compilation and execution)
of java programs. It's a software package
that contains tools and libraries needed for
compilation and execution of java
programs.

Mrs. Soniya Sharma [email protected]


Java Runtime Environment (JRE)

• JRE provides a runtime environment to your program for it's execution. As soon as you
start running your program using java command, the job of JRE starts and it ends when
either the program ran successfully or any error is thrown.

• JRE is also a software package which contains JVM, runtime libraries and other
supporting files needed to run a program.

Mrs. Soniya Sharma [email protected]


Java Virtual Machine (JVM)

• As soon as you run your program, a java virtual


machine is created which has some default size of
memory available for loading and executing classes,
objects, variables etc of a program.
• The machine loads not only your class(program) but
also other required classes and libraries which are
needed to execute the program.
• The execution of every Java program is under the
control of the JVM, it contains the program and prevent
it from generating side effects outside
Mrs. Soniya of the
Sharma system.
[email protected]
Installing IntelliJ IDEA

• We will be using IntelliJ IDK


• For windows -https://www.jetbrains.com/idea/download/?section=windows
• For ubuntu - Download IntelliJ IDEA – The Leading Java and Kotlin IDE (jetbrains.com)
• For macOS - Download IntelliJ IDEA – The Leading Java and Kotlin IDE (jetbrains.com)
• However, following are few Java IDEs which can be used for writing java programs:
• IntelliJ IDEA
• Eclipse
• NetBeans
• BlueJ
• Jdeveloper
Mrs. Soniya Sharma [email protected]
Writing a simple java program
Program 1

class Simple{
public static void main(String args[]){
System.out.println(“Welcome To Lets Upgrade!!!");
}
}

Mrs. Soniya Sharma [email protected]


Writing a simple java program

Program 2

Mrs. Soniya Sharma [email protected]


Writing a simple java program

OUTPUT

Mrs. Soniya Sharma [email protected]


Data Types, Variables & Operators

Mrs. Soniya Sharma [email protected]


Think & Tell

Which type of data will be stored in this form?

Mrs. Soniya Sharma [email protected]


Datatypes

• A data type in Java represents the size and different values that can be stored in a
variable.

Mrs. Soniya Sharma [email protected]


Variable
• A variable is a container which holds the value while the Java program is executed. A
variable is assigned with a data type.
• Variable is a name of memory location. There are three types of variables in java: local,
instance and static.

Note: Instance &Mrs. Soniya Sharma [email protected]


Static variables will be discussed in future sprint.
Rules to Declare a Variable
• A variable name can consist of Capital letters A-Z, lowercase letters a-z digits 0-9, and two
special characters such as _ underscore and $ dollar sign.

• The first character must not be a digit.

• Blank spaces cannot be used in variable names.

• Java keywords cannot be used as variable names.

• Variable names are case-sensitive.

• There is no limit on the length of a variable name but by convention, it should be between 4
to 15 chars.

• Variable names always shouldMrs.


exist
Soniya on the
Sharma left-hand side of assignment operators.
[email protected]
Rules to Declare a Variable

Mrs. Soniya Sharma [email protected]


Initializing values to variables

Mrs. Soniya Sharma [email protected]


Operators

Mrs. Soniya Sharma [email protected]


Arithmetic Operators

Mrs. Soniya Sharma [email protected]


Relational Operators

Mrs. Soniya Sharma [email protected]


Unary Operators

Mrs. Soniya Sharma [email protected]


Ternary/Conditional
Operator

Mrs. Soniya Sharma [email protected]


Logical Operators

• And (&&)
• OR (||)
• Not(~)

Mrs. Soniya Sharma [email protected]


Scanner Class

Mrs. Soniya Sharma [email protected]


Control Flow Statements

Mrs. Soniya Sharma [email protected]


if and if-else construct

• If Construct

Output

Mrs. Soniya Sharma [email protected]


Predict the output

Mrs. Soniya Sharma [email protected]


Output

Mrs. Soniya Sharma [email protected]


If-else Construct

Mrs. Soniya Sharma [email protected]


If-else-if Construct

Mrs. Soniya Sharma [email protected]


Nested If-else Construct

Mrs. Soniya Sharma [email protected]


Switch case

Mrs. Soniya Sharma [email protected]


Loops

Types of Loops

Mrs. Soniya Sharma [email protected]


Loops

Mrs. Soniya Sharma [email protected]


Loops
Predict the Output

Mrs. Soniya Sharma [email protected]


Loops

Mrs. Soniya Sharma [email protected]


Loops
Predict the Output

Mrs. Soniya Sharma [email protected]


Loops

Mrs. Soniya Sharma [email protected]


Loops
Predict the Output

Mrs. Soniya Sharma [email protected]


break and continue Statements

Mrs. Soniya Sharma [email protected]


break and continue Statements

Mrs. Soniya Sharma [email protected]


break and continue Statements

Mrs. Soniya Sharma [email protected]


String

Mrs. Soniya Sharma [email protected]


Declare and initialize a string

Mrs. Soniya Sharma [email protected]


Immutability of Strings

Mrs. Soniya Sharma [email protected]


String Pool

Mrs. Soniya Sharma [email protected]


Immutability of Strings

Mrs. Soniya Sharma [email protected]


Comparing String

Mrs. Soniya Sharma [email protected]


Comparing String

Mrs. Soniya Sharma [email protected]


Comparing String

Mrs. Soniya Sharma [email protected]


Comparing String

Mrs. Soniya Sharma [email protected]


Manipulate String

Mrs. Soniya Sharma [email protected]


Manipulate String

Mrs. Soniya Sharma [email protected]


Manipulate String

Mrs. Soniya Sharma [email protected]


Manipulate String

Mrs. Soniya Sharma [email protected]


Manipulate String

Mrs. Soniya Sharma [email protected]


Manipulate String

Mrs. Soniya Sharma [email protected]


String Methods

Mrs. Soniya Sharma [email protected]


THANK YOU

➢ Ms. Soniya Sharma


[email protected]

www.linkedin.com/in/soniya-p-sharma

Mrs. Soniya Sharma [email protected]

You might also like