Java Daily Notes

Super :-
---------

public class Car extends Vehical{

String carType;
SeatBealt sb;
String colour="Red";

{
System.out.println("car");
}

Car(){
super(100);
System.out.println("zero org constructor-Car");
}


Car get() {
super.get();
System.out.println("sub class method");
return this;
}

@Override
public String toString() {
return "Car [carType=" + carType +" "+ super.colour+"]";
}
}


public class Vehical {

int vehNo;
int cost;
String colour = "White";
String model;

{
System.out.println("vehical");
}

Vehical() {
System.out.println("zero org constructor-vehical");
}

Vehical(int vehNo) {
System.out.println("org constructor-vehical" + vehNo);
}

Vehical get() {
System.out.println("super class method");
return this;
}

@Override
public String toString() {
return "Vehical [vehNo=" + vehNo + ", cost=" + cost + ", colour=" + colour + ", model=" + model + "]";
}
}



public class Test {

public static void main(String[] args) {
Car car=new Car();
car.get();
System.out.println(car);
}
}

------------------------------------------------------------------------------------------------------------------
This Key Word :-

public class Student {

int rollNo;
String name;
float marksPercentage;

Student(int rollNo, String name) {
this(rollNo, name, 35);
this.rollNo = rollNo;
// name=name;
this.name = name;

}
Student(int rollNo, String name, long marksPercentage) {
this.rollNo = rollNo;
this.name = name;
this.marksPercentage = marksPercentage;

}

public void getMsg() {
System.out.println("method");
this.getMsg1(this);
this.printName(this.name);
}
public void getMsg1(Student student) {
System.out.println("method1 1 call : " + student);
}
public void printName(String name) {
System.out.println(name);
}

@Override
public String toString() {
return "Student [rollNo=" + rollNo + ", name=" + name + ", marksPercentage=" + marksPercentage + "]";
}
}


public class Test {

public static void main(String[] args) {
Student student = new Student(100, "baya");
System.out.println(student);
student.getMsg();
}
}


---------------------------------------------------------------------
public class Employee {

int empNo;
String name;
int sal;
    static String company;
 
    /*static{
    System.out.println("static");
    }*/
 
    public static void  getStaticMsg(){
    System.out.println("static method ");
    getStaticMsg1();
    Employee emp=new Employee();
    emp.m();
    System.out.println("Name  : "+emp.name);
    }
 
    public static void  getStaticMsg1(){
    System.out.println("static method1");
    }
 
    public void getMsg(){
    System.out.println("non static method");
    m();
    getStaticMsg1();
    }
 
    public void m(){
    System.out.println("m");
    }
 

}




-----------------------------------------
public class Test {



public static void main(String args[]){

System.out.println(Employee.company);
Employee.getStaticMsg();

System.out.println("-----------------");
Employee emp=new Employee();
System.out.println("emp no : "+emp.empNo);
System.out.println("emp name : "+emp.name);
emp.getMsg();


///Employee.getMsg();
















/*emp.empNo=100;
emp.company="wfd";
System.out.println(Employee.company);
///Employee.getStaticMsg();
System.out.println("emp no : "+emp.empNo);
System.out.println("Copany name : "+emp.company);
System.out.println("-----------------------");
Employee emp1=new Employee();

System.out.println("emp no : "+emp1.empNo);
System.out.println("Copany name : "+emp1.company);

System.out.println("-----------------------");
Employee emp2=new Employee();

System.out.println("emp no : "+emp2.empNo);
System.out.println("Copany name : "+emp2.company);
System.out.println("-----------------------");
emp2.empNo=111;
emp2.company="wfdlabs";
System.out.println("emp no : "+emp2.empNo);
System.out.println("Copany name : "+emp2.company);

System.out.println("-----------------------");
Employee emp3=new Employee();

System.out.println("emp no : "+emp3.empNo);
System.out.println("Copany name : "+emp3.company);*/

}
}

Comments

  1. Hi Team,
    Please please go through this java introduction class notes:

    ReplyDelete
  2. what is java?
    -java is a programming langauage founded by james gasling in 1995.
    -java is a high level,robust,object-oriented and secure programming.

    There are 4 different platforms in java.
    1)Java SE(Java standard edition).
    -It includes java fundamentals,oops,Strings,Exception,Multi threading,Collections etc)
    2)Java EE(Java enterprise edition).
    -it includes servlets,jsp,RMI,EJB ,REST API etc).
    3)Java ME(Java micro edition):
    -This edition used to develop the mobile apps.
    4)Java FX:
    -This is used to develop the rich UI based applications.
    ex:JSF.

    Java features:
    1)Simple:
    --java is very easy to learn and its very clean,and also it follows c++ syntax.
    2)Object-oriented:
    --Basic concepts of oops are:
    1.objects.
    2.class.
    3.Inhecritance.
    4.Polymarphism.
    5.Abstraction.
    6.Encapsulation.

    3)Portable:
    --java is portable becuase of we can transaform the bytecode to any other platforms.

    4)Platform-independent:
    --Java is Platform independent becuase the compiler generates the bytecode ie .class file.so that we can run this on any
    any platform like windows,linux,mc os ,solaris etc.

    5)Secured.
    --java sucured becuase
    1)There is no explicit pointers.
    2)it runs on JVM.
    3)Bytecode verifier.
    4)Security manager.

    6)Robust:
    --it uses strong memory management in JVM.
    --there is no pointers.
    --There is a Garbage collection which runs on the virtual machine to clean up the java objects.
    --Exception handling.

    7)Architectural neutral:
    --The size of primitive types are fixed in 32 bit os and 64-bit os.
    8)Multi threaded.
    --we can write java programs that executes many tasks at once by multiple threads.
    9)Distributed:
    --Java is distributed via RMI and EJB,webservices(SOAP,REST).

























    ReplyDelete

Post a Comment

Popular posts from this blog

Spring Boot + Maven + RestFul + JPA + Sqlite

View & Materialized View

JDBC with Sqlite