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

Java Basics

Java is a high-level, object-oriented programming language designed for platform independence, allowing code to run on any system with a Java Virtual Machine (JVM). Key components include the Java Runtime Environment (JRE) for execution and the Java Development Kit (JDK) for development. The document also covers basic concepts such as variables, data types, operators, control flow statements, access specifiers, constructors, and core object-oriented programming principles.

Uploaded by

nik27s.sbi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java Basics

Java is a high-level, object-oriented programming language designed for platform independence, allowing code to run on any system with a Java Virtual Machine (JVM). Key components include the Java Runtime Environment (JRE) for execution and the Java Development Kit (JDK) for development. The document also covers basic concepts such as variables, data types, operators, control flow statements, access specifiers, constructors, and core object-oriented programming principles.

Uploaded by

nik27s.sbi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Introduction to Java

(Java basic concepts)


INTRODUCTION
Java is a high-level, class-based, object-oriented programming language that is
designed to have as few implementation dependencies as possible.

It is a general-purpose programming language intended to let programmers write once,


run anywhere (WORA), meaning that compiled Java code can run on all platforms that
support Java without the need to recompile.

Java applications are typically compiled to bytecode that can run on any Java virtual
machine (JVM) regardless of the underlying computer architecture.
JVM, JRE & JDK
 Java Virtual Machine: The Java Virtual Machine (JVM) is a virtual machine that
enables a computer to run Java programs as well as programs written in other
languages that are also compiled to Java bytecode.

 Java Runtime Environment: The JRE provides the necessary resources for
executing Java programs on a computer. It ensures that your compiled Java code can
run smoothly.

 Java Development Kit: The Java Development Kit (JDK) is a software development
kit used by Java developers to build, compile, debug, and deploy Java applications. It
includes a collection of tools, libraries, and components necessary for Java
development.
HELLO WORLD !

class HelloWorld {

public static void main(String[] args) {

System.out.println("Hello, World!");

Output : Hello, World!


VA R I A B L E S & D ATAT Y P E S
Variables: A variable is a named storage location in memory where you can store data.

Variables allow you to manipulate and work with values in your Java programs. Before using a
variable, you must declare it with a specific data type.

The syntax for declaring a variable is: data_type variable_name;

Data Types: Data types specify the kind of data that can be stored in a variable. Java has two
main categories of data types.

i) Primitive Data Types

ii) Reference Data Types


D ATAT Y P E S ( C O N T D . . )
Primitive Data Types: These are the most basic building blocks for storing data. They represent raw values
and are not considered objects. The eight primitive data types in Java are:
byte: An 8-bit signed integer with a range from -128 to 127.
short: A 16-bit signed integer with a range from -32,768 to 32,767.
int: A 32-bit signed integer with a range from -2,147,483,648 to 2,147,483,647. It can also represent unsigned
integers using the Integer class.
long: A 64-bit signed integer with a wider range.
float: A 32-bit floating-point number for decimal values.
double: A 64-bit floating-point number with higher precision.
char: A 16-bit Unicode character.
boolean: Represents true or false values.

Reference Data Types: These include classes, interfaces, and arrays. They store references (memory
addresses) to objects rather than the actual data.
O P E R AT O R S
In Java, operators are symbols that perform various operations on variables and
values.

 Arithmetic Operators ( +, -, *, /, %, ++, -- )

 Assignment Operators (=, +=, -=)

 Comparison Operators ( ==, !=, >, <, >=, <= )

 Logical Operators ( &&, || )

 Unary Operators ( !, - )
C O N T R O L F L O W S TAT E M E N T S
In Java, control flow statements allow you to change the execution path of your
program based on certain conditions.

Decision-Making Statements: if & switch

Loop Statements: for, while & do-while

Branching Statements: break, continue & return


A C C E SS S P E C I F I E R S
In Java, access specifiers help control the visibility and accessibility of classes,
methods, constructors, and fields. They determine which parts of your code can be
accessed from other classes or packages.

 Default

 Public

 Private

 Protected
CONSTRUCTOR METHOD & THIS
KEYWORD

Constructor Method: In Java, a constructor is a special method that is invoked when


an instance of a class is created. It plays a crucial role in initializing the object.

“this” keyword: The “this” keyword in Java serves a fundamental purpose: it refers to
the current object. In other words, this represents the instance of the class where it’s
used.
O O P S C O N C E P T S I N J AVA
 Class

 Object

 Inheritance

 Polymorphism

 Encapsulation
T H A N K YO U

You might also like