0% found this document useful (0 votes)
9 views

2.3 Data types

hehe
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)
9 views

2.3 Data types

hehe
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/ 10

Data types and Comments

Outline

1. Data types and Memory allocation


2. Types of variables and Scopes of Variables
3. Naming Conventions
4. Interview Questions
Data Types and Memory Allocation

Java is a strongly typed language. This means that every variable must have a
declared type. There are eight primitive types in Java.
● Four integer types
○ byte, short, int, long
● Two floating-point number types
○ float (6-7 decimal digits)
○ double(15 decimal digits)
● one character type
● one a boolean type
Rules of Identifiers

Identifiers in Java are names that identify elements such as classes, variables, and
methods in a program. In other words, an identifier is one that is for naming variables,
user-defined methods, classes, objects, parameters, labels, packages, and interfaces in a
program.

● Java identifier is a sequence of characters that consists of letters, digits, underscores


(_), and dollar signs ($).
● It must start with a letter, an underscore (_), or a dollar sign ($). It cannot begin with a
digit.
● It cannot be a reserved word.
● It cannot be true, false, or null.
● It cannot contain !@#$%^&*()_+-=\|/.,<>?”:;’ signs.
● It can be of any length.

Oracle Documentation
Note: Using $ sign for variable naming is not recommended by oracle.
Comment types

● Single line comment


● Multi line comment
● Java documentation comment
Types of variables and Scopes of Variables

Types of variables Scopes of Variables

● Local variables ● Method Level Scope


● Instance variables ● Object Level Scope
● Class/Static variables ● Class Level Scope
Naming conventions

Naming Conventions Programming Case Types

● Packages ● camelCase
● Classes ● PascalCase
● Interfaces ● snake_case
● Methods ● kebab-case
● Variables ● MACRO_CASE
● Constants ● Train-Case

Oracle Documentation
Interview Questions
The only thing standing between you and outrageous
success is continuous progress.

You might also like