Wednesday, 4 April 2018

Multiple inheritance in java using interface







package javaapplication26;



interface employee

{

   

void printemployeedetails(String n,int id);





}



interface teacher

{



void printteacherdetails(String batch,int id);



}



class teamleader implements employee,teacher

{

   

public void printemployeedetails(String n,int id)

{

    System.out.println("Name of Employee is "+n);

    System.out.println("Employee id : "+id);

}



public void printteacherdetails(String batch,int id)

{

 System.out.println("Batch code: "+batch);

    System.out.println("Teacher id : "+id);

}





public void showleaderdetials(String n)

{

    System.out.println("Team leader name is "+n);

}



}









public class JavaApplication26



{



 

    public static void main(String[] args)

    {

      teamleader tl=new teamleader();

      tl.printemployeedetails("salman", 2245);

      tl.printteacherdetails("1708C1", 4332);

      tl.showleaderdetials("salman");

    }

   

}


Multiple inheritance in java using interface







package javaapplication26;



interface employee

{

   

void printemployeedetails(String n,int id);





}



interface teacher

{



void printteacherdetails(String batch,int id);



}



class teamleader implements employee,teacher

{

   

public void printemployeedetails(String n,int id)

{

    System.out.println("Name of Employee is "+n);

    System.out.println("Employee id : "+id);

}



public void printteacherdetails(String batch,int id)

{

 System.out.println("Batch code: "+batch);

    System.out.println("Teacher id : "+id);

}





public void showleaderdetials(String n)

{

    System.out.println("Team leader name is "+n);

}



}









public class JavaApplication26



{



 

    public static void main(String[] args)

    {

      teamleader tl=new teamleader();

      tl.printemployeedetails("salman", 2245);

      tl.printteacherdetails("1708C1", 4332);

      tl.showleaderdetials("salman");

    }

   

}


Monday, 2 April 2018

interfaces in java (Abstraction in OOP)







package javaapplication25;





interface shape

{



    void area();

 

}

class square implements shape

{

float s;

 public void area()

 {

     System.out.println("area of square is "+s*s);

 }





}



public class JavaApplication25 {



   

    public static void main(String[] args)

    {

       square s= new square();

        s.s=10;

       s.area();

   

       

    }

   

}


Abstraction in java (Object Oriented Programming pillar)







package javaapplication24;



abstract class shape

{



public abstract void printarea();



}

class triangle extends shape

{

   float b,h;

public  void printarea()

{

    System.out.println("area of triangle is "+0.5*b*h);

}

}



class square extends shape

{

    float s;

public  void printarea()

{

    System.out.println("area of triangle is "+s*s);

}



}







public class JavaApplication24 {



 

    public static void main(String[] args)

    {

        triangle t=new triangle();

        t.b=5;

        t.h=10;

        t.printarea();

   

        square s=new square();

        s.s=2.5f;

        s.printarea();

   

    }

   

}


Wednesday, 28 March 2018

Encapsulation in java







package javaapplication23;



class employee

{

private int emp_id ;

private String emp_name ;



public void setid(int value)

{

    emp_id=value;

}

public int getid()

{

 return emp_id; 

}





public void setname(String value)

{

    emp_name=value;

}

public String getname()

{

 return emp_name; 

}









}







public class JavaApplication23 {



   

    public static void main(String[] args)   

    {

        employee e=new employee();

       e.setid(1);

       e.setname("ali");

     

        System.out.println("EMPLOYEE ID "+e.getid());

        System.out.println("EMPLOYEE Name "+e.getname());

       

       

     

     

    }

   

}



Access modifier in java







package javaapplication21;





class A

{

  protected  String name="abcd"; 

private void msg1()

{

    System.out.println("hello this is msg1 and private");

}



protected void msg2()

{

    System.out.println("hello this is msg2 and protected");

}



}



class B extends A

{

public void showname()

{

 System.out.println("name is "+name);

}

}

public class JavaApplication21

{

    public static void main(String[] args)

    {

    B a=new B();

    a.msg2();

    a.showname();



     

     

       

    }

   

}


Wednesday, 21 March 2018

Super Keyword in java





package superkeyword;



class mamal

{

public String color="blue";



public void eat()

{

    System.out.println("It eats.....");

}

public void reproduces()

{

    System.out.println("It gives birth to a new living being.....");

}





}



class blueWhale extends mamal

{

 

public String Color=super.color;   

public void swim()

{

    System.out.println("It swims in sea.......");

}

   

public void allactions()

{

    super.eat();

    super.reproduces();

    swim();



}





}













public class Superkeyword {



 

    public static void main(String[] args)

   

    {

       

        blueWhale bw=new blueWhale();

        System.out.println("color is "+ bw.Color);

        bw.allactions();

   

    }

   

}


Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...