Unit 2.1
Unit 2.1
Structure
in Java
CONCEPT OF OBJECT
ORIENTATION
Three types of programs in Java:
Stand-alone application programs These are
made and run on users’ computers.
Boolean Literal
• These are Boolean values. There are only
two values—true or false.
LITERALS IN JAVA
Character Literal
• These are the values in characters.
• Characters are represented in single quotes
such as ‘A’, ‘H’, ‘k’, and so on.
String Literals
• These are strings of characters in double
quotes. Examples are “Delhi”, “John”, “AA”,
etc.
Null Literal
There is only one value of Null Literal, that is, null.
SEPERATOS IN JAVA
Separators
OPERATORS IN JAVA
There are 37 operators in Java
OPERATORS IN JAVA..CONT
OPERATORS IN JAVA
There are 37 operators in Java
DECLARATION OF
VARIABLES
• Variables are objects whose values may
change in the program.
• A variable is declared by first writing its
type, followed by its name or identifier.
TYPES OF VARIABLES
Local variables These are declared inside a
method or are arguments to a method.
Instance variables These variables may be
declared anywhere in a class but outside
a method.
- Associated with objects.
- Created when objects are instantiated.
- Take different values for each object.
TYPES OF VARIABLES
Static or class variables
- The declaration of these variables is
modified by the keyword static.
1. Single-line comment
2. Multi-line comment
3. Documentation comment
COMMENTS
Single-line comment It starts after a double slash
(//) up to the end of the line. E.g.
//This is single line comment.