Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Introduction to Java

Programming
Welcome to the world of Java programming! In this presentation, we will explore
the basics, including classes, objects, variables, datatypes, and control
statements.

by CHETHAN RAJ
1. Classes in Java
1 Definition
A class is a blueprint or template that defines the properties and behavior of objects.

2 Syntax
Create a class using the keyword "class", followed by the class name and a pair of curly braces.

3 Example
public class MyClass { }
2. Objects in Java

Definition Syntax Example


An object is an instance of a class Create an object using the "new" MyClass obj = new MyClass();
that has its own state and keyword followed by the class
behavior. name and parentheses.
3. Variables in Java
1 Definition
A variable is a named memory location that stores a value.

2 Syntax
Declare a variable by specifying the datatype, followed by the variable name.

3 Example
int num;
4. Types of Variables
Local variables Instance variables
Defined inside a method or block and have Belong to an instance of a class and are
limited scope. declared outside any method.

Static variables
Shared by all instances of a class and are declared with the "static" keyword.
5. Datatypes in Java
Primitive Datatypes Reference Datatypes

byte String

short Array

int Class

long Interface

float Object

double

char

boolean
6. Different Datatypes in Java

Numeric Datatypes String Datatype Array Datatype


Includes byte, short, int, long, Used to store a sequence of Used to store multiple values of
float, and double. characters. the same type.
7. Conditional Statements in Java
1 If Statement 2 Switch Statement
Executes a block of code if the specified Selects one of many code blocks to be
condition is true. executed.
8. Decision-Making Statements in Java

1 For Loop
Repeats a block of code a fixed number of times.

2 While Loop
Repeats a block of code while a specified condition is true.

3 Do-While Loop
Repeats a block of code while a specified condition is true, at least once.

You might also like