Wednesday 14 March 2018

METHOD OVERLOADING IN JAVA


package javaapplication16;

class calculator
{

    public int sum(int x,int y)
    {
    return x+y;
    }

   public int sum(int x,int y,int z)
    {
    return x+y+z;
    }
 
 
   public double sum(double x,double y,double z)
    {
    return x+y+z;
    }
 

}




public class JavaApplication16
{

   
    public static void main(String[] args)
    {
        calculator c=new calculator();
        double r =c.sum(3, 4, 10);
       
        System.out.println("sum is "+r);
   
    }
   
}

Aggregation in java


package aggregate;

class Address
{

 int zipcode; 
String city,street;

public Address(int zc,String cit,String st) // parametrized constructor.........
{
this.zipcode=zc;
this.street=st;
this.city=cit;
   
}
   
   
}

class employee
{
int emp_id ;
String name;
double salary;
Address a;

public employee(int id,String name,double salary,Address ad)
{
this.emp_id=id;
this.name=name;
this.salary=salary;
this.a=ad;

}


void display()
{
    System.out.println("Emp id= "+emp_id);
    System.out.println("Emp Name= "+name);
    System.out.println("Emp Salary= "+salary);
    System.out.println("Emp Address= "+a.zipcode+" - "+a.street+" - "+a.city);
   
   
}


}





public class Aggregate {

 
    public static void main(String[] args)
    {
        Address ad=new Address(78650,"Karachi","Street-2");
        employee emp=new employee(541,"salman",76000,ad);
        emp.display();

       
    }
   
}

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 ...