Core Java Part1
Core Java Part1
JAVA: Java is a high level programming language which supports all the Oops Principles.
ADVANTAGES OF JAVA :
5.)Java Provides Rich built-in Libraries,which helps user to perform the complex jobs easily.
Encapsulation,Inheritance,Polymorphism,Abstraction.
PRINTING STATEMENTS:
1.) System.out.print() : Print will print the data and move the cursor to next position of same line.
2.) System.out.println(): Println will print the data and move the cursor to initial position of next line.
Rules:
Sensitive Language
Ex: class,public,static..etc…..
known as Identifier.
Like: Variables,Methods,class,Interface.
Rules:
3. Literals: The Data Written by the Programmer in the Program is called as Literals.
1.Number literals:
---> Integers,Decimals.
2.Character literals: In java anything that we write within single quotes(‘ ’) is known as Characters.
*In java if we want to pass any string ,it is mandatory to pass within double quotes.
4.Boolean Literals: It Represents logical data, there are 2 logical values . (True, False).
Variable: Variable is a Named Block Of Memory, Where we can store or fetch the data using name.
*The Name provided by the user to the Container created is known as Variable.
Characterstics of Variable:
Note:
CREATE A VARIABLE:
*Datatype: It is Used to Specify size and type of data can be stored inside the container/variable.
*) Types of Datatypes:
i) Primitive datatypes.
or single block.
Byte,short,int,long,float,double,char,Boolean…( 8 types ).
ii) Non Primitive Datatype: The datatypes which are used to store non
LOCAL VARIABLE:
2.) we can use the local variable only inside the block where it is
scope.
OPERATORS:
Operators are pre-defined Symbols,which is used to perform a specific task on the operands
Types Of Operators:
i) Unary Operator: An Operator which can accept only one operand is known as Unary Operator.
Ex: Logical not , new , Typecast Operator, Increment & Decrement Operators etc……
ii) Binary Operator: An Operator which can accept only 2 operands is known as Binary Operator.
iii) Ternary Operator: An Operator which can accept only 3 Operands is known as Ternary Operator.
i) Arithmetic Operator:
*)Division Operator: Whenever we are using division operator(/),the compiler will give the Quotient as
Output.
*)Modulus Operator: Whenever we are using Modulus operator(%),the compiler will give the Reminder
as Output.
*) They can be used only along with Variables which are the primitive types…. Except the Boolean.
*) It is a Ternary Operator.
*) In Conditional Operator ,the first operand must be of type boolean i.e we can directly write Boolean
literal or We can have an Expression which returns Boolean.
*) The ReturnType of Conditional Op is always depends on the datatype of Op2 & Op3.
Some Questions:
*) It is a binary operator.
i) Logical And(&&)
i)Logical And(&&):
*) It is a Binary operator.
*) The And Operator are used whenever it is mandatory to satisfy all the conditions to be performed.
*) In Logical And Operator if the First Condition is returning us false, we can directly say result will be
false itself.
*) if the first condition is false then compiler will never check second condition.
ii)Logical OR(||):
*) It is a Binary operator.
*) The OR Operator are used whenever we can perform a task ,even if any one of the condition is
satisfied. It returns true itself.
iii)Logical Not(!):
*) It is a Unary operator.
*) Whenever we are working with Not Operator & if we are passing an expression to it, we must pass
that expression within parenthesis().
i) It is a Binary Operator.
a.)Widening
b.)Narrowing
TypeCast Operator:
*) It is a Unary Operator.