8. Java Language Fundamentals / 8 of 28
Basics of the Java Language
Classes & Methods
Data types
Variables
Operators
Control structures
9. Java Language Fundamentals / 9 of 28
Classes in Java
Class declaration Syntax
class Classname
{
var_datatype variablename;
:
met_datatype methodname(parameter_list)
:
}
11. Java Language Fundamentals / 11 of 28
Nested Classes
Defining one class within another is called
‘Nesting’
Types:
Static
Non-static
12. Java Language Fundamentals / 12 of 28
Data Types
byte
char
boolean
short
int
long
float
double
Array
Class
Interface
13. Java Language Fundamentals / 13 of 28
Type Casting
One data type is converted into another data
type
Example
float c = 34.89675f;
int b = (int)c + 10;
14. Java Language Fundamentals / 14 of 28
Variables
Three components of a variable declaration:
Data type
Name
Initial value to be assigned (optional)
Syntax
datatype identifier [=value][, identifier[=value]...];
16. Java Language Fundamentals / 16 of 28
Array Declarations
Three ways for Array Declaration:
datatype identifier [ ];
datatype identifier [ ] = new datatype[size];
datatype identifier [ ]= {value1,value2,….valueN};
17. Java Language Fundamentals / 17 of 28
Methods in Classes
A method is defined as the actual
implementation of an operation on an object
Syntax
access_specifier modifier datatype method_name(parameter_list)
{
//body of method
}
20. Java Language Fundamentals / 20 of 28
Method Modifiers
static
abstract
final
native
synchronized
volatile
21. Java Language Fundamentals / 21 of 28
Methods Overloading
Overloaded Methods:
Are in the same class
Have the same name
Have different parameter lists
Overloaded methods are a form of compile
time polymorphism
22. Java Language Fundamentals / 22 of 28
Methods Overriding
Overridden Methods:
Are in the superclass as well as the subclass
Are redefined in the subclass
Overridden methods are a form of runtime
polymorphism
23. Java Language Fundamentals / 23 of 28
Class Constructors
Special method used to initialize member
variables of the class
Same name as the Class name and does
not have a return type
Called when an object is created
Types:
Explicit constructors
Implicit constructors
24. Java Language Fundamentals / 24 of 28
Derived class constructors
Has the same name as the subclass
Statement that calls the constructor of the
superclass should be the first statement in
the constructor of a subclass
25. Java Language Fundamentals / 25 of 28
Operators
Java Provides following categories of Operators:
Arithmetic Operators
Bitwise Operators
Relational Operators
Logical Operators
Conditional Operators
Assignment Operators
28. Java Language Fundamentals / 28 of 28
Control Flow
Decision – making
if-else statement
Switch-else statement
Loops
while loop
do-while loop
for loop
29. Want to contact Unit Nexus
Unit Nexus Zirakpur Official Website
Like Unit Nexus Pvt. Ltd. On Facebook
Add Unit Nexus to your professional Network
on Linked In
Company Profile of Unit Nexus
Java Language Fundamentals / 29 of 28