Create a Super Class : Student.java having name,rollNumber
Create a Subclass JavaStudent.java extending Student.java. Add a constructor to intialize name and rollNumber.
Create a Client program . Create an instance of Student and access the name and rollNumber
Assignment :2
Given the below Code , What will be the result
- Code: Select all
public class TestDays {
public enum Days {
MON, TUE, WED
};
public static void main(String[] args) {
for (Days d : Days.values());
Days[] d2 = Days.values();
System.out.println(d2[2]);
}
}
Assignment: 3
What is the output of the below Code
- Code: Select all
public class Test extends Hobbit {
public static void main(String[] args) {
Short myGold = 7;
System.out.println(countGold(myGold, 6));
}
}
class Hobbit {
int countGold(int x, int y) {
return x + y;
}
}
Assignment 4:
What is the output of the below Code
- Code: Select all
enum Animals {
DOG("woof"), CAT("meow"), FISH("burble");
String sound;
Animals(String s) {
sound = s;
}
}
class TestEnum {
static Animals a;
public static void main(String[] args) {
System.out.println(a.DOG.sound + " " + a.FISH.sound);
}
}