BIRLA INSTITUTE OF TECHNOLOGY & SCIENCE, PILANI
SOFTWARE DEVELOPMENT & EDUCATIONAL TECHNOLOGY UNIT
SDET C102, CORE JAVA
LAB-3 : 05/10/07

1)Write a class called Sys in utils package. In this class write methods say print() and println() ( similar to System.out.print() and System.out.println() ).  Write your methods in such a way that they accept different datatypes (overload them). Inside these methods call System.out.print & System.out.println. Use these methods through out today's lab wherever you need to write to console(command prompt).

2)Write a class called Account with following attributes name, accountNumber, balance, address. Use appropriate data types for these attributes. Use access control to prevent direct access of these attributes from outside the class. write methods that allow you to read these variables and also change them (if change is permitted). Write another class called AccountDemo and instantiate an object of Account class. Test your methods and print values

eg: String getName( )  &  void setName(String name)

create all the methods following the above naming convention

3)
class X{

    int a;

    public X( int a){

        this.a=a;

    }

}

write a class Y that inherits from X. Also write main method within class Y and try to create objects of both X and Y.

hint: you are not allowed to overload constructor in X. use Super

4) create an abstract class called Animal and create at least three classes ( Dog, Snake, Fish etc.,) which extend from that class and override the abstract methods defined in animal class. (Print different values for different animals when you override methods in Animal class)

import utils.*;

public abstract class Animal{

public abstract void move();

public abstract void eat();

public void sleep(){

Sys.println(i am sleeping”);

}

}

Then create another class called AnimalDemo and write a method called with the following signature:

live(Animal);

In this method invoke some methods of Animal. Your main method should be written in AnimalDemo class.