SlideShare a Scribd company logo
By :
Anuj Kumar Raghav
Assistant Professor
www.akraghav.com2020-21
AKR Education
www.akreducation.com
 Installation
 Tokens
 Variables
 Data types
 Naming Convention In Java
Some PCs might have Java already installed.
 To check if you have Java installed on a
Windows PC, type the following in Command
Prompt (cmd.exe):
C:UsersYour Name>java -version
 If Java is installed, you will see something like
this (depending on version):
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build
11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build
11.0.1+13-LTS, mixed mode)
Continued…
 If you do not have Java installed on your computer, you
can download JDK(Java development Kit) for free
from oracle.com.
 Install the JDK.
 After Installation , Setting Path for Java.
 Step: 1 Right click on My Computer icon and select properties.
Or
Go to "System Properties" (Can be found on Control Panel > System
and Security > System > Advanced System Settings)
 Step: 2 Go to Advance Setting Tab
 Step: 3 Click on Environment Variable Button
Step:4 Then, select the "Path" variable in System
variables and click on the "Edit" button.
 Click on the "New" button and add the path where Java is
installed, followed by bin. By default, Java is installed
in C:Program FilesJava……
 You will have to add a new path with: C:Program
FilesJava…… and press OK.
 At last, open Command Prompt (cmd.exe) and
type java -version to see if Java is running on your
machine.
To write your Java programs, you will need a text
editor.
 Notepad − On Windows machine, you can use any
simple text editor like Notepad (Recommended for
this tutorial), TextPad.
 Netbeans − A Java IDE that is open-source and free
which can be downloaded
from https://www.netbeans.org/index.html.
 Eclipse − A Java IDE developed by the eclipse open-
source community and can be downloaded
from https://www.eclipse.org/.
public class FirstJava
{
public static void main(String[] args)
{
System.out.println("Welcome in Aims");
}
}
Explanation :
 class: class is a keyword is used to declare classes in java.
 public: It is an access specifiers. Public means this
function is visible to all.
 static: static is used to make a function static. To execute
a static function you do not have to create an Object
of the class. The main () method here is called by
jvm, without creating any object for class.
 void: void is return type, meaning this function will not
return anything.
 main(): This is the method which is executed hence all logic
must be inside the main() method. If a java class is
not having a main() method, it causes compilation
error.
 System.out.println(): This is used to print anything on the
consol like printf()in
Continued…
Steps to compile and Run FirstJava Program
 Step: 1 Open a text editor like Notepad and write the
code of First Java Program.
 Step: 2 save the file as FirstJava.java
 Step: 3 Open command prompt and go to the
directory where you saved your first java
program.
Step: 4 Type javac FirstJava.java then enter to
compile the program.
Step: 5 Now Type java FirstJava on command prompt
the enter to run program.
 “Each and every smallest individual unit in a
program is known as tokens.”
 The keywords, identifiers, constants, string
literals, and operators are examples of
tokens. Punctuation characters such as brackets
[ ], braces { }, parentheses ( ), and commas (,)
are also tokens.
“A variable is a container which holds the value while
the Java program is executed. A variable is assigned
with a data type.”
There are three types of variables in Java:
1) local variable 2) Instance variable 3) static variable
1) Local Variable :
A variable declared inside the body of the method is called
local variable. You can use this variable only within that
method and the other methods in the class aren't even
aware that the variable exists.
A local variable cannot be defined with "static" keyword.
Continued…
2) Instance Variable :
A variable declared inside the class but outside
the body of the method, is called instance
variable. It is not declared as static.
3) Static variable :
A variable which is declared as static is called
static variable. It cannot be local. You can
create a single copy of static variable and share
among all the instances of the class. Memory
allocation for static variable happens only once
when the class is loaded in the memory.
Example
class A
{
int data=50;//instance variable
static int m=100;//static variable
void method()
{
int n=90;//local variable
}
}
“ Data types specify the different sizes and values
that can be stored in the variable.”
There are two types of data types in Java:
1) Primitive data types (PDT)
2) Non-primitive data types (NPDT)
1) Primitive data types :
A primitive data type specifies the size and type of
variable values, and it has no additional methods.
Continued…
There are eight primitive data types in Java:
Continued…
Data Type Size Description
byte 1 byte Stores whole numbers from -128 to 127
short 2 bytes Stores whole numbers from -32,768 to 32,767
int 4 bytes Stores whole numbers from -2,147,483,648 to
2,147,483,647
long 8 bytes Stores whole numbers from -
9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
float 4 bytes Stores fractional numbers. Sufficient for
storing 6 to 7 decimal digits
double 8 bytes Stores fractional numbers. Sufficient for
storing 15 decimal digits
boolean 1 bit Stores true or false values
char 2 bytes Stores a single character/letter or ASCII
values
2) Non-primitive data types :
“ Non-primitive data types are called reference
types because they refer to objects.”
( Examples : Strings, Arrays, Classes, Interface, etc.)
Difference between (PDT) and (NPDT) are:
 PDT are predefined in Java. NPDT are created by the
programmer and is not defined by Java (except for String).
 NPDT can be used to call methods to perform certain
operations, while PDT cannot.
 A PDT has always a value, while NPDT can be null.
 A PDT starts with a lowercase letter, while NPDT starts with an
uppercase letter.
 The size of a PDT depends on the data type, while NPDT have
all the same size.
 Class : start with the uppercase letter.
Ex:-(public class Employee)
 Interface : start with the uppercase letter.
Ex:-(interface Printable )
 Method : start with lowercase letter.
Ex:- main(), print(), println().
 Variable : start with a lowercase letter.
1) It should not start with the special characters like &
(ampersand), $ (dollar), _ (underscore).
2) Multiple words, start it with the lowercase letter
followed by an uppercase letter such as firstName.
 Constant : uppercase letters such as RED, YELLOW.
Unit 1 of java part 2 basic introduction

More Related Content

PPTX
Lecture - 2 Environment setup & JDK, JRE, JVM
PPTX
Lecture - 1 introduction to java
PPTX
Unit1 introduction to Java
DOCX
Java interview questions and answers for cognizant By Data Council Pune
PPTX
Multithreading in java
PPT
Core Java Programming | Data Type | operator | java Control Flow| Class 2
PPT
Java static keyword
DOCX
SQL Interview Questions For Experienced
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 1 introduction to java
Unit1 introduction to Java
Java interview questions and answers for cognizant By Data Council Pune
Multithreading in java
Core Java Programming | Data Type | operator | java Control Flow| Class 2
Java static keyword
SQL Interview Questions For Experienced

What's hot (20)

PPT
Java API, Exceptions and IO
PPTX
Unit 4 exceptions and threads
PPS
Packages and inbuilt classes of java
PPTX
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
PDF
Serialization & De-serialization in Java
PPTX
6. static keyword
PPTX
Java applet
PDF
Class method object
PPT
Core java
PPT
Java tutorial for Beginners and Entry Level
PPTX
Statics in java | Constructors | Exceptions in Java | String in java| class 3
PPTX
Unit3 part1-class
PPTX
Core java complete ppt(note)
PPT
Java basic tutorial by sanjeevini india
PDF
Java Serialization
PDF
Java Reflection
PPT
Core java concepts
PPT
Java tut1
PPT
Tutorial java
PPT
Core java concepts
Java API, Exceptions and IO
Unit 4 exceptions and threads
Packages and inbuilt classes of java
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
Serialization & De-serialization in Java
6. static keyword
Java applet
Class method object
Core java
Java tutorial for Beginners and Entry Level
Statics in java | Constructors | Exceptions in Java | String in java| class 3
Unit3 part1-class
Core java complete ppt(note)
Java basic tutorial by sanjeevini india
Java Serialization
Java Reflection
Core java concepts
Java tut1
Tutorial java
Core java concepts
Ad

Similar to Unit 1 of java part 2 basic introduction (20)

PDF
Java programming basics
PDF
Introduction java programming
PDF
02 basic java programming and operators
DOCX
OOP-Chap2.docx
PPTX
Java subject for the degree BCA students
PPTX
Java OOP Concepts 1st Slide
PDF
Basic Java Programming
PPTX
Java Notes
PPTX
Java Notes by C. Sreedhar, GPREC
PDF
College Project - Java Disassembler - Description
PDF
Java basic concept
PPTX
objectorientedprogrammingCHAPTER 2 (OOP).pptx
PPTX
JAVA UNIT 2
PDF
Object Oriented Programming with Java Basic Syntax.pdf
PPTX
Core Java Tutorials by Mahika Tutorials
PPTX
Java programing language unit 1 introduction
PPTX
Object Oriented Programming unit 1 content for students
PPT
Introduction
PPT
Basic java part_ii
PPTX
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
Java programming basics
Introduction java programming
02 basic java programming and operators
OOP-Chap2.docx
Java subject for the degree BCA students
Java OOP Concepts 1st Slide
Basic Java Programming
Java Notes
Java Notes by C. Sreedhar, GPREC
College Project - Java Disassembler - Description
Java basic concept
objectorientedprogrammingCHAPTER 2 (OOP).pptx
JAVA UNIT 2
Object Oriented Programming with Java Basic Syntax.pdf
Core Java Tutorials by Mahika Tutorials
Java programing language unit 1 introduction
Object Oriented Programming unit 1 content for students
Introduction
Basic java part_ii
JAVA AND OOPS CONCEPTS.pptx helpful for engineering
Ad

More from AKR Education (6)

PPTX
Unit 1 of c++ first program
PPTX
Unit 1 of dbms part 1 basic introduction
PPTX
Unit 1 of c++ part 1 basic introduction
PPTX
Unit 1 of java part 1 basic introduction akr
PPTX
Online classes platform & method
PPTX
Traffic sign recognition
Unit 1 of c++ first program
Unit 1 of dbms part 1 basic introduction
Unit 1 of c++ part 1 basic introduction
Unit 1 of java part 1 basic introduction akr
Online classes platform & method
Traffic sign recognition

Recently uploaded (20)

PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Presentation on HIE in infants and its manifestations
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
master seminar digital applications in india
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Cell Structure & Organelles in detailed.
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Presentation on HIE in infants and its manifestations
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
master seminar digital applications in india
Module 4: Burden of Disease Tutorial Slides S2 2025
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Final Presentation General Medicine 03-08-2024.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
01-Introduction-to-Information-Management.pdf
A systematic review of self-coping strategies used by university students to ...
Cell Structure & Organelles in detailed.
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Pharma ospi slides which help in ospi learning
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
GDM (1) (1).pptx small presentation for students
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Final Presentation General Medicine 03-08-2024.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

Unit 1 of java part 2 basic introduction

  • 1. By : Anuj Kumar Raghav Assistant Professor www.akraghav.com2020-21 AKR Education www.akreducation.com
  • 2.  Installation  Tokens  Variables  Data types  Naming Convention In Java
  • 3. Some PCs might have Java already installed.  To check if you have Java installed on a Windows PC, type the following in Command Prompt (cmd.exe): C:UsersYour Name>java -version  If Java is installed, you will see something like this (depending on version): java version "11.0.1" 2018-10-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode) Continued…
  • 4.  If you do not have Java installed on your computer, you can download JDK(Java development Kit) for free from oracle.com.  Install the JDK.  After Installation , Setting Path for Java.  Step: 1 Right click on My Computer icon and select properties. Or Go to "System Properties" (Can be found on Control Panel > System and Security > System > Advanced System Settings)
  • 5.  Step: 2 Go to Advance Setting Tab
  • 6.  Step: 3 Click on Environment Variable Button
  • 7. Step:4 Then, select the "Path" variable in System variables and click on the "Edit" button.  Click on the "New" button and add the path where Java is installed, followed by bin. By default, Java is installed in C:Program FilesJava……
  • 8.  You will have to add a new path with: C:Program FilesJava…… and press OK.  At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running on your machine.
  • 9. To write your Java programs, you will need a text editor.  Notepad − On Windows machine, you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad.  Netbeans − A Java IDE that is open-source and free which can be downloaded from https://www.netbeans.org/index.html.  Eclipse − A Java IDE developed by the eclipse open- source community and can be downloaded from https://www.eclipse.org/.
  • 10. public class FirstJava { public static void main(String[] args) { System.out.println("Welcome in Aims"); } }
  • 11. Explanation :  class: class is a keyword is used to declare classes in java.  public: It is an access specifiers. Public means this function is visible to all.  static: static is used to make a function static. To execute a static function you do not have to create an Object of the class. The main () method here is called by jvm, without creating any object for class.  void: void is return type, meaning this function will not return anything.  main(): This is the method which is executed hence all logic must be inside the main() method. If a java class is not having a main() method, it causes compilation error.  System.out.println(): This is used to print anything on the consol like printf()in Continued…
  • 12. Steps to compile and Run FirstJava Program  Step: 1 Open a text editor like Notepad and write the code of First Java Program.  Step: 2 save the file as FirstJava.java  Step: 3 Open command prompt and go to the directory where you saved your first java program.
  • 13. Step: 4 Type javac FirstJava.java then enter to compile the program. Step: 5 Now Type java FirstJava on command prompt the enter to run program.
  • 14.  “Each and every smallest individual unit in a program is known as tokens.”  The keywords, identifiers, constants, string literals, and operators are examples of tokens. Punctuation characters such as brackets [ ], braces { }, parentheses ( ), and commas (,) are also tokens.
  • 15. “A variable is a container which holds the value while the Java program is executed. A variable is assigned with a data type.” There are three types of variables in Java: 1) local variable 2) Instance variable 3) static variable 1) Local Variable : A variable declared inside the body of the method is called local variable. You can use this variable only within that method and the other methods in the class aren't even aware that the variable exists. A local variable cannot be defined with "static" keyword. Continued…
  • 16. 2) Instance Variable : A variable declared inside the class but outside the body of the method, is called instance variable. It is not declared as static. 3) Static variable : A variable which is declared as static is called static variable. It cannot be local. You can create a single copy of static variable and share among all the instances of the class. Memory allocation for static variable happens only once when the class is loaded in the memory.
  • 17. Example class A { int data=50;//instance variable static int m=100;//static variable void method() { int n=90;//local variable } }
  • 18. “ Data types specify the different sizes and values that can be stored in the variable.” There are two types of data types in Java: 1) Primitive data types (PDT) 2) Non-primitive data types (NPDT) 1) Primitive data types : A primitive data type specifies the size and type of variable values, and it has no additional methods. Continued…
  • 19. There are eight primitive data types in Java: Continued… Data Type Size Description byte 1 byte Stores whole numbers from -128 to 127 short 2 bytes Stores whole numbers from -32,768 to 32,767 int 4 bytes Stores whole numbers from -2,147,483,648 to 2,147,483,647 long 8 bytes Stores whole numbers from - 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 float 4 bytes Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits double 8 bytes Stores fractional numbers. Sufficient for storing 15 decimal digits boolean 1 bit Stores true or false values char 2 bytes Stores a single character/letter or ASCII values
  • 20. 2) Non-primitive data types : “ Non-primitive data types are called reference types because they refer to objects.” ( Examples : Strings, Arrays, Classes, Interface, etc.) Difference between (PDT) and (NPDT) are:  PDT are predefined in Java. NPDT are created by the programmer and is not defined by Java (except for String).  NPDT can be used to call methods to perform certain operations, while PDT cannot.  A PDT has always a value, while NPDT can be null.  A PDT starts with a lowercase letter, while NPDT starts with an uppercase letter.  The size of a PDT depends on the data type, while NPDT have all the same size.
  • 21.  Class : start with the uppercase letter. Ex:-(public class Employee)  Interface : start with the uppercase letter. Ex:-(interface Printable )  Method : start with lowercase letter. Ex:- main(), print(), println().  Variable : start with a lowercase letter. 1) It should not start with the special characters like & (ampersand), $ (dollar), _ (underscore). 2) Multiple words, start it with the lowercase letter followed by an uppercase letter such as firstName.  Constant : uppercase letters such as RED, YELLOW.

Editor's Notes