II B.Tech II Sem CSE Java Lab Exercise - 3 a(Class, Objects)

a) Implementing Class & Objects
Aim: To write a JAVA program to implement class mechanism. – Create a class, methods and invoke them inside main method.
Description:




Programs:


1.no return type and without parameter-list:

class A
{
int l=10,b=20; 
void display() 
{
System.out.println(l); 
System.out.println(b);

}
class methoddemo 
{
public static void main(String args[]) 
{
A a1=new A();
a1.display(); 
}
}

Output:


2.no return type and with parameter-list:

class A 
{
void display(int l,int b) 
{
System.out.println(l);
System.out.println(b); 
}
}
class methoddemo1 
{
public static void main(String args[]) 
{
A a1=new A();
a1.display(10,20); 
}
}

Output:



3.return type and without parameter-list
class A 
{
int l=10,b=20;
int area() 
{
return l*b; 
}
}
class methoddemo2 
{
public static void main(String args[]) 
{
A a1=new A();
int r=a1.area(); 
System.out.println("The area is: "+r); 
}
}

Output:


4.return type and with parameter-list:

class A 
{
int area(int l,int b) 
{
return l*b; 
}
}
class methoddemo4
{
public static void main(String args[]) 
{
A a1=new A();
int r=a1.area(10,20); 
System.out.println("The area is:"+r);

}

Output:







No comments

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...