use of static keyword in java example
import java.io.*;
class overloaddemo
{
void test()
{
System.out.println("No arguments");
}
void test(int a)
{
System.out.println("a"+a);
}
void test(int a,int b)throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
int c=a+b;
System.out.println("sum"+c);
}
}
class over
{
public static void main(String args[]) throws IOException
{
int a=0,b=0;
overloaddemo ob=new overloaddemo();
ob.test();
ob.test(10);
ob.test(a,b);
}
static
{
System.out.println("hai");
}
}
No comments:
Post a Comment