SlideShare a Scribd company logo
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
UNIT-2
[Naming Conventions in Java. Data types in Java, Literals]
Naming Conventions in Java
Java naming convention is a rule to follow as you decide what to name your identifiers such as
class, package, variable, constant, method etc. But, it is not forced to follow. So, it is known as
convention not rule.
Below are some naming conventions of for java programming language, which must be followed
while developing software in java for good maintenance and readability of code. Java uses
CamelCase as a practice for writing names of methods, variables, classes, packages and constants.
If name is combined with two words, second word will start with uppercase letter always e.g.
actionPerformed(), firstName, etc.
1. Classes and Interfaces:
● Class names should be nouns, in mixed case with the first letter of each internal word
capitalized. Interfaces name should also be capitalized just like class names.
● Use whole words and must avoid acronyms and abbreviations.
Examples:
class CseStudent
Interface FootBall
2. Methods :
● Methods should be verbs, in mixed case with the first letter lowercase and with the first
letter of each internal word capitalized.
Examples:
void speedUp(int increment)
3. Variables :
● Variable names should be short yet meaningful.
● Should not start with underscore(‘_’) or dollar sign ‘$’ characters.
● Should be mnemonic i.e, designed to indicate the intent of its use.
● One-character variable names should be avoided except for temporary variables, such as
i, j, k, m, and n for integers; c, d, and e for characters.
Examples:
int rollNo;
4. Constant variables:
● Should be all uppercase with words separated by underscores (“_”).
● There are various constants used in predefined classes like Float, Long, String etc.
Examples:
static final int MIN_WIDTH = 4;
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
5. Packages:
● The prefix of a unique package name is always written in all-lowercase ASCII lettersand
should be one of the top-level domain names, like com, edu, gov, mil, net, org.
● Subsequent components of the package name vary according to an organization’s own
internal naming conventions.
Examples:
com.sun.eng
Data Types in java
Data type is a special type of keyword which is useful for allocating sufficient memory for that data.
In other words, Java Data Types are the classification, to identify one of various types of data such
as real number, integer, floating point or boolean. That determines the possible values for that
particular type and the operations that can be done on values of that type.
So, Java data types are in various forms to store the different types of information. These Java data
types are mainly classified into 2 types.
(a) Primitive Data Types and
(b) Non-Primitive Data Types.
Java data types can not be modified once they declared.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
The primitive data types in Java are also called as Fundamental data types or Basic data types. In
primitive, Java data types are mainly classified into four types. They are Integer Data Types In Java,
Floating-Point Data Types In Java, Character Data Types in Java and Boolean Data Types in Java.
Following table shows the details related to primitive data types:
In Non-Primitive, Java data types are further classified into three types. User defined data type is
one of these Non-primitive Java data types. According to the requirement we can choose the
appropriate type in Java data types.
There are three types of variables in java:
• local variable
• instance variable
• static variable
1) Local Variable: A variable which is declared inside the method is called local variable.
2) Instance Variable: A variable which is declared inside the class but outside the method, is called
instance variable. It is not declared as static.
3) Static variable: A variable that is declared as static is called static variable. It cannot be local.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
Literals
Literals in Java are a sequence of characters (digits, letters, and other characters) that represent
constant values to be stored in variables. Java language specifies five major types of literals.
1. Integer Literals: Java has several integer literals: int, long, byte, and short. We can specify
the integers either in decimal, hexadecimal or octal format. To indicate a decimal format
put the left most digit as nonzero. Similarly use the prefix ox to indicate hexadecimal and to
indicate the octal format put a zero digit followed by the digits 0 to 7.
Examples:
int decimal = 100;
int octal = 0144;
int hexa = 0x64;
An integer literal larger than an int can hold is automatically considered to be of the type
long. You also can indicate that a literal should be a long integer by adding the letter L (L or
l) to the number.
2. Floating-point Literals: Floating-point literals use a period character (.) for the decimal
point. Java has two kinds of floating-point numbers: float and double. The default type when
you write a floating-point literal is double. However, the suffix F (or f) is appended to
designate the data type of a floating-point literal as float.
Examples:
double myGPA = 2.25;
float piValue = 3.1415927F;
We can also specify a floating-point literal in scientific notation using Exponent (E or e). For
instance: the double literal 0.0314E2 is interpreted as: 0.0314 *10² (i.e 3.14).
3. Character Literals: Character literals are expressed by a single character surrounded by
single quotation marks, such as 'a', '#', and '3'. Some character literals represent characters
that are not readily printable or accessible through a keyboard. Following Table lists the
special codes that can represent these special characters as well as characters from the
Unicode character set. The letter d in the octal, hex, and Unicode escape codes represents a
number or a hexadecimal digit (a–f or A–F).
Escape Meaning
n New line
t Tab
b Backspace
r Carriage return
f Formfeed
 Backslash
' Single quotation mark
" Double quotation mark
d Octal
xd Hexadecimal
ud Unicode character
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
4. String Literals: The set of characters in represented as String literals in Java. Always use
"double quotes" for String literals. A string in Java is an object rather than being a basic data
type, and strings are not stored in arrays as they are in languages such as C. There are few
methods provided in Java to combine strings, modify strings and to know whether to strings
have the same value.
Example:
String myString = "How are you?";
5. Boolean Literals: The values true and false are also treated as literals in Java programming.
When we assign a value to a boolean variable, we can only use these two values.
Example
boolean chosen = true;
Provided By Shipra Swati

More Related Content

What's hot

7. name binding and scopes
7. name binding and scopes7. name binding and scopes
7. name binding and scopes
Zambales National High School
 
Jason yousef ssis expressions - no notes
Jason yousef   ssis expressions - no notesJason yousef   ssis expressions - no notes
Jason yousef ssis expressions - no notesjasonyousef
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++
Deepak Singh
 
Structure and Enum in c#
Structure and Enum in c#Structure and Enum in c#
Structure and Enum in c#
Prasanna Kumar SM
 
concept of oops
concept of oopsconcept of oops
concept of oops
prince sharma
 
The Go Programing Language 1
The Go Programing Language 1The Go Programing Language 1
The Go Programing Language 1
İbrahim Kürce
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
Subhasis Nayak
 
Data types IN JAVA
Data types IN JAVAData types IN JAVA
Data types IN JAVA
garishma bhatia
 
Java Programming
Java Programming Java Programming
Java Programming
RubaNagarajan
 
Literals,variables,datatype in C#
Literals,variables,datatype in C#Literals,variables,datatype in C#
Literals,variables,datatype in C#
Prasanna Kumar SM
 
Regular Expression in Compiler design
Regular Expression in Compiler designRegular Expression in Compiler design
Regular Expression in Compiler design
Riazul Islam
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
NIDA HUSSAIN
 
Oop concepts classes_objects
Oop concepts classes_objectsOop concepts classes_objects
Oop concepts classes_objects
William Olivier
 
Basic of java 2
Basic of java  2Basic of java  2
Basic of java 2
Vijay Kankane
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
Identifiers and keywords
Identifiers and keywordsIdentifiers and keywords
Identifiers and keywords
Logicinprogramming
 

What's hot (20)

7. name binding and scopes
7. name binding and scopes7. name binding and scopes
7. name binding and scopes
 
Jason yousef ssis expressions - no notes
Jason yousef   ssis expressions - no notesJason yousef   ssis expressions - no notes
Jason yousef ssis expressions - no notes
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++
 
Structure and Enum in c#
Structure and Enum in c#Structure and Enum in c#
Structure and Enum in c#
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
The Go Programing Language 1
The Go Programing Language 1The Go Programing Language 1
The Go Programing Language 1
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Variables
VariablesVariables
Variables
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
 
Data types IN JAVA
Data types IN JAVAData types IN JAVA
Data types IN JAVA
 
Java Programming
Java Programming Java Programming
Java Programming
 
Literals,variables,datatype in C#
Literals,variables,datatype in C#Literals,variables,datatype in C#
Literals,variables,datatype in C#
 
Regular Expression in Compiler design
Regular Expression in Compiler designRegular Expression in Compiler design
Regular Expression in Compiler design
 
Introduction to c++
Introduction to c++Introduction to c++
Introduction to c++
 
C plusplus
C plusplusC plusplus
C plusplus
 
Oop concepts classes_objects
Oop concepts classes_objectsOop concepts classes_objects
Oop concepts classes_objects
 
Basic of java 2
Basic of java  2Basic of java  2
Basic of java 2
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Regular expression (compiler)
Regular expression (compiler)Regular expression (compiler)
Regular expression (compiler)
 
Identifiers and keywords
Identifiers and keywordsIdentifiers and keywords
Identifiers and keywords
 

Similar to Java unit 2

Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
Marwa Ali Eissa
 
Java Tokens
Java  TokensJava  Tokens
Java_Roadmap.pptx
Java_Roadmap.pptxJava_Roadmap.pptx
Java_Roadmap.pptx
ssuser814cf2
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
BG Java EE Course
 
Introduction to Java Object Oiented Concepts and Basic terminologies
Introduction to Java Object Oiented Concepts and Basic terminologiesIntroduction to Java Object Oiented Concepts and Basic terminologies
Introduction to Java Object Oiented Concepts and Basic terminologies
TabassumMaktum
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
Madishetty Prathibha
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
SaqlainYaqub1
 
Overview of java Language-3.pdf
Overview of java Language-3.pdfOverview of java Language-3.pdf
Overview of java Language-3.pdf
kumari36
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGEPRASANYA K
 
Full CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languageFull CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java language
ssuser2963071
 
7-Java Language Basics Part1
7-Java Language Basics Part17-Java Language Basics Part1
7-Java Language Basics Part1
Amr Elghadban (AmrAngry)
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
IJERD Editor
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
rishi ram khanal
 
CHAPTER 3 - VALUE AND DATA TYPES LECTURE 1.pdf
CHAPTER 3 - VALUE AND DATA TYPES LECTURE 1.pdfCHAPTER 3 - VALUE AND DATA TYPES LECTURE 1.pdf
CHAPTER 3 - VALUE AND DATA TYPES LECTURE 1.pdf
arbazkhan950274
 
C tokens
C tokensC tokens
C tokens
Megha Sharma
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
MayaTofik
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
İbrahim Kürce
 
Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
sandeshjadhav28
 

Similar to Java unit 2 (20)

Data Types, Variables, and Operators
Data Types, Variables, and OperatorsData Types, Variables, and Operators
Data Types, Variables, and Operators
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
java
java java
java
 
Java_Roadmap.pptx
Java_Roadmap.pptxJava_Roadmap.pptx
Java_Roadmap.pptx
 
Introduction to-programming
Introduction to-programmingIntroduction to-programming
Introduction to-programming
 
Introduction to Java Object Oiented Concepts and Basic terminologies
Introduction to Java Object Oiented Concepts and Basic terminologiesIntroduction to Java Object Oiented Concepts and Basic terminologies
Introduction to Java Object Oiented Concepts and Basic terminologies
 
Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
 
Lecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptxLecture2_MCS4_Evening.pptx
Lecture2_MCS4_Evening.pptx
 
Overview of java Language-3.pdf
Overview of java Language-3.pdfOverview of java Language-3.pdf
Overview of java Language-3.pdf
 
C PROGRAMMING LANGUAGE
C  PROGRAMMING  LANGUAGEC  PROGRAMMING  LANGUAGE
C PROGRAMMING LANGUAGE
 
Full CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languageFull CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java language
 
7-Java Language Basics Part1
7-Java Language Basics Part17-Java Language Basics Part1
7-Java Language Basics Part1
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
CHAPTER 3 - VALUE AND DATA TYPES LECTURE 1.pdf
CHAPTER 3 - VALUE AND DATA TYPES LECTURE 1.pdfCHAPTER 3 - VALUE AND DATA TYPES LECTURE 1.pdf
CHAPTER 3 - VALUE AND DATA TYPES LECTURE 1.pdf
 
C tokens
C tokensC tokens
C tokens
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
 
Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
 

More from Shipra Swati

Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
Shipra Swati
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
Shipra Swati
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-Introduction
Shipra Swati
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
Shipra Swati
 
Java unit 14
Java unit 14Java unit 14
Java unit 14
Shipra Swati
 
Java unit 12
Java unit 12Java unit 12
Java unit 12
Shipra Swati
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
Shipra Swati
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
Shipra Swati
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
Shipra Swati
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
Shipra Swati
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manual
Shipra Swati
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
Shipra Swati
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
Shipra Swati
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
Shipra Swati
 
Fundamental of Information Technology
Fundamental of Information TechnologyFundamental of Information Technology
Fundamental of Information Technology
Shipra Swati
 
Disk Management
Disk ManagementDisk Management
Disk Management
Shipra Swati
 
File Systems
File SystemsFile Systems
File Systems
Shipra Swati
 
Memory Management
Memory ManagementMemory Management
Memory Management
Shipra Swati
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
Shipra Swati
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
Shipra Swati
 

More from Shipra Swati (20)

Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-Introduction
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
 
Java unit 14
Java unit 14Java unit 14
Java unit 14
 
Java unit 12
Java unit 12Java unit 12
Java unit 12
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manual
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
 
Fundamental of Information Technology
Fundamental of Information TechnologyFundamental of Information Technology
Fundamental of Information Technology
 
Disk Management
Disk ManagementDisk Management
Disk Management
 
File Systems
File SystemsFile Systems
File Systems
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 

Recently uploaded

Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 

Recently uploaded (20)

Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 

Java unit 2

  • 1. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE UNIT-2 [Naming Conventions in Java. Data types in Java, Literals] Naming Conventions in Java Java naming convention is a rule to follow as you decide what to name your identifiers such as class, package, variable, constant, method etc. But, it is not forced to follow. So, it is known as convention not rule. Below are some naming conventions of for java programming language, which must be followed while developing software in java for good maintenance and readability of code. Java uses CamelCase as a practice for writing names of methods, variables, classes, packages and constants. If name is combined with two words, second word will start with uppercase letter always e.g. actionPerformed(), firstName, etc. 1. Classes and Interfaces: ● Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Interfaces name should also be capitalized just like class names. ● Use whole words and must avoid acronyms and abbreviations. Examples: class CseStudent Interface FootBall 2. Methods : ● Methods should be verbs, in mixed case with the first letter lowercase and with the first letter of each internal word capitalized. Examples: void speedUp(int increment) 3. Variables : ● Variable names should be short yet meaningful. ● Should not start with underscore(‘_’) or dollar sign ‘$’ characters. ● Should be mnemonic i.e, designed to indicate the intent of its use. ● One-character variable names should be avoided except for temporary variables, such as i, j, k, m, and n for integers; c, d, and e for characters. Examples: int rollNo; 4. Constant variables: ● Should be all uppercase with words separated by underscores (“_”). ● There are various constants used in predefined classes like Float, Long, String etc. Examples: static final int MIN_WIDTH = 4; Provided By Shipra Swati
  • 2. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE 5. Packages: ● The prefix of a unique package name is always written in all-lowercase ASCII lettersand should be one of the top-level domain names, like com, edu, gov, mil, net, org. ● Subsequent components of the package name vary according to an organization’s own internal naming conventions. Examples: com.sun.eng Data Types in java Data type is a special type of keyword which is useful for allocating sufficient memory for that data. In other words, Java Data Types are the classification, to identify one of various types of data such as real number, integer, floating point or boolean. That determines the possible values for that particular type and the operations that can be done on values of that type. So, Java data types are in various forms to store the different types of information. These Java data types are mainly classified into 2 types. (a) Primitive Data Types and (b) Non-Primitive Data Types. Java data types can not be modified once they declared. Provided By Shipra Swati
  • 3. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE The primitive data types in Java are also called as Fundamental data types or Basic data types. In primitive, Java data types are mainly classified into four types. They are Integer Data Types In Java, Floating-Point Data Types In Java, Character Data Types in Java and Boolean Data Types in Java. Following table shows the details related to primitive data types: In Non-Primitive, Java data types are further classified into three types. User defined data type is one of these Non-primitive Java data types. According to the requirement we can choose the appropriate type in Java data types. There are three types of variables in java: • local variable • instance variable • static variable 1) Local Variable: A variable which is declared inside the method is called local variable. 2) Instance Variable: A variable which is declared inside the class but outside the method, is called instance variable. It is not declared as static. 3) Static variable: A variable that is declared as static is called static variable. It cannot be local. Provided By Shipra Swati
  • 4. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE Literals Literals in Java are a sequence of characters (digits, letters, and other characters) that represent constant values to be stored in variables. Java language specifies five major types of literals. 1. Integer Literals: Java has several integer literals: int, long, byte, and short. We can specify the integers either in decimal, hexadecimal or octal format. To indicate a decimal format put the left most digit as nonzero. Similarly use the prefix ox to indicate hexadecimal and to indicate the octal format put a zero digit followed by the digits 0 to 7. Examples: int decimal = 100; int octal = 0144; int hexa = 0x64; An integer literal larger than an int can hold is automatically considered to be of the type long. You also can indicate that a literal should be a long integer by adding the letter L (L or l) to the number. 2. Floating-point Literals: Floating-point literals use a period character (.) for the decimal point. Java has two kinds of floating-point numbers: float and double. The default type when you write a floating-point literal is double. However, the suffix F (or f) is appended to designate the data type of a floating-point literal as float. Examples: double myGPA = 2.25; float piValue = 3.1415927F; We can also specify a floating-point literal in scientific notation using Exponent (E or e). For instance: the double literal 0.0314E2 is interpreted as: 0.0314 *10² (i.e 3.14). 3. Character Literals: Character literals are expressed by a single character surrounded by single quotation marks, such as 'a', '#', and '3'. Some character literals represent characters that are not readily printable or accessible through a keyboard. Following Table lists the special codes that can represent these special characters as well as characters from the Unicode character set. The letter d in the octal, hex, and Unicode escape codes represents a number or a hexadecimal digit (a–f or A–F). Escape Meaning n New line t Tab b Backspace r Carriage return f Formfeed Backslash ' Single quotation mark " Double quotation mark d Octal xd Hexadecimal ud Unicode character Provided By Shipra Swati
  • 5. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE 4. String Literals: The set of characters in represented as String literals in Java. Always use "double quotes" for String literals. A string in Java is an object rather than being a basic data type, and strings are not stored in arrays as they are in languages such as C. There are few methods provided in Java to combine strings, modify strings and to know whether to strings have the same value. Example: String myString = "How are you?"; 5. Boolean Literals: The values true and false are also treated as literals in Java programming. When we assign a value to a boolean variable, we can only use these two values. Example boolean chosen = true; Provided By Shipra Swati