JAVA
JAVA
ARRAY
-->Single Dimensional
-->Two Dimensional
Three Dimensional
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DATATYPES
1. Primitive --> int, float, double, long, char, short, byte, boolean
2. Non-Primitive --> Classes, Interface, Arrays
***********************************************************************************
***********************
Classes --> enclosed Variables(to store DATA) & Methods(to store Programming Logic)
-->
class
main
int x=; // Local Variable
int y=; // Local Variable
int sum=x+y+a;
SOP(sum);
--> Instance & Static variables which outside the methods are also known as GLOBAL
Variables
--> Static methods can only access the static stuff --> Main Method is related to
static
-->TEMPLATE
class Car
String color;
String model;
int milage;
int cost;
public void startCar() //Non-Static --> from non-static we can access both static &
non-static
SOP(model+" ");
-->
class Demo
Main method
AUDI.color = "RED";
AUDI.model = "S model";
AUDI.milage = 17;
AUDI.cost = 1900000;
SOP("____________________");
AUDI.startCar();
AUDI.stopCar();
AUDI.carDetails();
SOP("____________________");
.equals()
.length()
###################################################################################
#################################################
class Car
String color;
String model;
int milage;
int cost;
-->
class Demo
Main method
BMW.startCar();
BMW.stopCar();
BMW.carDetails();
SOP("____________________");
AUDI.startCar();
AUDI.stopCar();
AUDI.carDetails();
SOP("____________________");
HONDA.startCar();
HONDA.stopCar();
HONDA.carDetails();
SOP("____________________");
this keyword --> when ISNTANCE variable & PARAMETER have same keyword, THIS keyword
is used to differentiate
OVERLOADING --> It is possible to create the multiple methods with the same name in
the class
--> PURPOSE - to use the properties(Variables & Methods) from one class to another
class
extends - Keyword
String Vincent;
String Pitt;
String QT;
main method
p.Car();
p.Gun();
SOP("___________________________");
f.film();
f.Car();
f.Gun();
SOP("___________________________");
-->
public interface Bank //Interface
-->
public class HDFC implements Bank // implements
-->
main method
b.bankBalance();
b.accountCharges();
b.loans();
--> EXCEPTION HANDLING - Errors which are not idetified during compile time and
occur while the code is being executed.
-->
main method
SOP("BEFORE");
try{
int a=10/0;
}catch(Exception e){
SOP("Handled");
}
SOP("AFTER");
###################################################################################
###################################################################################
############
******************************METHODS*******************************
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ OBJECTS$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
class Animal
{
public void eat()
{
SOP("Dog Eating");
}
main method()
{
Animal choco = new Animal();
choco.eat();
choco.run();
}
public void run()
{
SOP("Dog Running");
}
}
1. By Reference variable
2. By Method
3. By Constructor -->
is a block similar to method having same as class name
Does not have any return type, not even void
The only modifiers applicable for constructor are public, protected, default
& private
It executes automatically when we create an object
used to initialize the object
class Employee
{
String name;
int emp_id;
main method
Employee e1 = new Employee("ALPHA", 100);
a. DEFAULT
b. NO-AURGUMENT
c. PARAMETRIZED
class Animal
{
void eat(){
SOP("EATING");}
}
class Dog extends Animal
{
main method{
Dog d = new Dog();
d.eat(); }
}
// Animal - Parent class
// Dog - child class
TYPES
--> a. Single Inheritance
--> b. Multi Level Inheritance
--> c. Hierarichal Inheritance
XX d. Multiple Inheritance
XX e. Hybrid Inheritance
Abstraction
Data Hiding
Encapsulation
Tight coupled classes
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ABSTRACTION
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Types
Abstract Class - can achieve 0-100%
Interface - can achieve 100%
INTERFACE
methods//abstract
fields
interface i1{
public void show();
}
class Test implements I1{
public void show(){
SOP("1");}
}
main method{
Test t = new Test();
t.show();
}