Assignment 2 Complete
Assignment 2 Complete
Set A
Write a java program to calculate area of Cylinder and Circle. (Use super keyword)
class Circle {
double radius;
Circle(double r) {
radius = r;
double area() {
double height;
Cylinder(double r, double h) {
super(r);
height = h;
double area() {
}
Assignment No. 2: Classes, Objects and Methods
Define an Interface Shape with abstract method area(). Write a java program to calculate an area of
interface Shape {
double area();
Circle(double r) {
radius = r;
Sphere(double r) {
radius = r;
Define an Interface "Integer" with a abstract method check().Write a Java program to check whether
interface IntegerCheck {
if (num > 0)
System.out.println("Positive Number");
System.out.println("Negative Number");
else
System.out.println("Zero");
obj.check(-15);
Define a class Student with attributes rollno and name. Define default and parameterized constructo
class Student {
Assignment No. 2: Classes, Objects and Methods
int rollno;
String name;
Student() {
count++;
Student(int r, String n) {
this.rollno = r;
this.name = n;
count++;
System.out.println(s1);
System.out.println(s2);
Write a java program to accept 'n' integers from the user & store them in an ArrayList collection. Dis
Assignment No. 2: Classes, Objects and Methods
import java.util.*;
int n = sc.nextInt();
list.add(sc.nextInt());
Collections.reverse(list);