24java
24java
class Student
String name;
int age;
name=n;
age=a;
System.out.println(name);
System.out.println(age);
Student()
System.out.println("constructor call");
Student(int asd)
System.out.println(asd);
obj.setname("Ram",20);
obj.show();
#Output-
2. WAP to illustrate static member of class in java programming.
public class StaticExample
{
static int age;
static String name;
//This is a Static Method
static void display()
{
System.out.println("Age is: "+age);
System.out.println("Name is: "+name);
}
// This is also a static method
public static void main(String [] args)
{
age = 30;
name = "Steve";
display();
}
}
#Output-
3. WAP to illustrate inheritance(“is a” relationship) in java programming.
class Student2
{
int roll,marks;
String name;
void input()
{
System.out.println("enter roll no,name and marks");
}
}
class Ayag extends Student2
{
void show()
{
roll=12;
name="Ayush";
marks=90;
System.out.println(roll+" "+name+" "+marks);
}
}
public class Simpleinheritance
{
public static void main(String[] agrs)
{
Ayag s1=new Ayag();
s1.input();
s1.show();
}
}
#Output-
4. WAP to illustrate association in java programming.
System.out.println(name);
System.out.println(age);
System.out.println(salary);
}
}
// Base class
public class Base {
public static void main(String args[])
{
Sunstar s = new Employee();
s.printInfo();
}
}
#Output-
9. WAP to illustrate interface in java programming.
interface Polygon {
void getArea(int length, int breadth);
}