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

Java Intro

Java is a high-level, portable, object-oriented programming language. It is a simple, secure, and platform independent language that supports object-oriented programming principles like encapsulation, inheritance, polymorphism, and abstraction. It provides rich built-in libraries and features like variables, data types, operators, and statements that make programming easier. Variables can be declared using data types to store and manipulate data in Java programs.

Uploaded by

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

Java Intro

Java is a high-level, portable, object-oriented programming language. It is a simple, secure, and platform independent language that supports object-oriented programming principles like encapsulation, inheritance, polymorphism, and abstraction. It provides rich built-in libraries and features like variables, data types, operators, and statements that make programming easier. Variables can be declared using data types to store and manipulate data in Java programs.

Uploaded by

ashish.singhqa17
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

JAVA

JAVA: java is a high level programming language which supports allthe


Oops Principles.

ADVANTAGES OF JAVA
1.)Java is a Simple Programming Language.
2.)Java is a Secured language.
3.)Java is a Portable language.
4.)Java is a Platform Independent Language.
5.)Java Provides Rich built-in Libraries,which helps user to perform
the complex jobs easily.
6.)Java Supports Oops Principles Such as
Encapsulation,Inheritance,Polymorphism,Abstraction.

DISPLAY STATEMENTS:
It is used to print the user written statements on the console.
*Java provides 2 display statements:
1.) System.out.print() : Print will print the data and move the cursor to
next position of same line.
*we cannot use it without passing the data.
2.) System.out.println(): Println will print the data and move the cursorto
initial position of next line.
*we can use it without passing the data also.

 BASIC STRUCTURE OF JAVA


Tokens: A Smallest unit or Component of any programming languageis
known as Tokens.
 Keyword: It is a Predefined meaning or Compiler Aware words are
called as Keywords.
Rules:
*We Cannot Change the Keywords.
 These are also known as Reserved Words.
 The Keywords must always be in Lower Case , Bcz java is a case
Sensitive Language
Ex: class,public,static..etc…..

 Identifier: Identifiers is a name given to the components of java.


Or
The name provided by the programmers to the members of java is
known as Identifier.
Like: Variables,Methods,class,Interface.
Rules:
*We Cannot Start Identifiers with Numeric Values.
*Except Dollar($) and Underscore(_) no other special Char are
allowed.
*We Cannot use Keywords as Identifiers.

Conventions: Industry Standards…

 Literals: The Data Written by the Programmer in the Program is


called as Literals.
 In java we have following literals
1.Number literals:
*we can pass the numericals values directly in java
---> Integers,Decimals.

 Character literals: In java anything that we write within single


quotes(‘ ’) is known as Characters
 we can’t pass more than one value.
*The length of character should be one.
---> Alphabets ,Digits and Special Char.

 String literals: String is a Group of Characters.


*In java if we want to pass any string ,it is mandatory to pass within
double quotes.

 Boolean Literals: It Represents logical data, there are 2 logical


values . (True, False).

VARIABLES AND DATATYPES


Variable: Variable is a Named Block Of Memory, Where we can storeor
fetch the data using name.
*The Name provided by the user to the Container created is known as
Variable.
 Variable can store the single value.
Characterstics of Variable:
*We can store or fetch the data using name.
*We can Store only one value.
*We cannot Store Multiple Values.

Note:
The data stored inside variable it is not permanent, it is Temporary
data.

CREATE A VARIABLE:
Syntax: datatype identifier; (Variable Declaration Stmt).
CREATE MULTIPLE VARIABLE IN SINGLE STMT:
Syntax: datatype identifier1,identifier2……identifier_n;

Variables : 1) Based on Datatypes :- Primitive & Non Primitive Variable.

2.) Based on Scope: Local Variable , static & non-static Variable .

1.)Primitive variable: The Variable created for Primitive datatype is


known as Primitive variables.

*Datatype: It is Used to Specify size and type of data can be stores


inside the container/variable.

*) Types of Datatypes:
 Primitive datatypes.
 Non primitive datatypes.

 Primitive Datatype: The datatypes which are used to store the


primitive data are known as Primitive datatypes.
*Primitive data: It is a data which can be stored in a single containeror
single block.
Primitive datatypes in java are:
Byte,short,int,long,float,double,char,Boolean…( 8 types ).

 Non Primitive Datatype: The datatypes which are used to store non
primitive data are known as non primitive datatypes.
*Non-primitive data: It is a multivalue data which cannot be stored in
one block of memory.
*we need multi block of memory.. such as Array,Object.
*In java every classname is a Non-primitive datatype.
*null keyword is the default value for all non-primitive datatypes.
*we can create non-primitive variables(Reference variables) with the
help of non-primitive datatype.

2. Non-Primitive Variable(Reference variable): The Variable created


for Non-Primitive datatype , Which is used to store reference/Address
of an Object/Array is known as Primitive variables.
LOCAL VARIABLE:
A Variable declared inside method block or initializer block or main
method or Any block , Except Class block is known as Local Variable.

Rules of Local variable:


1.) We cannot use local variable without Assigining the data.
2.) we can use the local variable only inside the block where it is
declared.( we cannot use outside the block).
3.) We cannot declare 2 local variable with same name inside the same
scope.

You might also like