Skip to content

teztripathy/TopGear-CoreJava-Assignment001

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TopGear-CoreJava-Assignment001 - by Tejeswar Tripathy

Core Java Assignment Eclipse Project

Core Java Assignments

  1. Write a program to print factorial of N ( without using any loop)

  2. There is an animal class which has the common characteristics of all animals. Dog, Horse, Cat are animals(sub-class). Each can shout, but each shout is different. Use polymorphism to create objects of same and using an animal variable, make each of the animals shout.

  3. Create an abstract class Instrument which is having the abstract function play.
    Create three more sub classes from Instrument which is Piano, Flute, Guitar. Override the play method inside all three classes printing a message “Piano is playing tan tan tan tan ” for Piano class “Flute is playing toot toot toot toot” for Flute class “Guitar is playing tin tin tin ” for Guitar class Create an array of 10 Instruments. Assign different type of instrument to Instrument reference. Check for the polymorphic behavior of play method.

  4. Write an interface called Playable, with a method void play(); Let this interface be placed in a package called music. Write a class called Veena which implements Playable interface. Let this class be placed in a package music.string. Write a class called Saxophone which implements Playable interface. Let this class be placed in a package music.wind. Write another class Test in a package called live. Then, a. Create an instance of Veena and call play() method b. Create an instance of Saxophone and call play() method c. Place the above instances in a variable of type Playable and then call play().

  5. Write a program to accept name and age of a person from the command prompt(passed as arguments when you execute the class) and ensure that the age entered is >=18 and < 60. Display proper error messages. The program must exit gracefully after displaying the error message in case the arguments passed are not proper. (Hint : Create a user defined exception class for handling errors.)

  6. Write a program to assign the current thread to t1. Change the name of the thread to MyThread.
    Display the changed name of the thread. Also it should display the current time.
    Put the thread to sleep for 10 seconds and display the time again.

  7. Create an ArrayList of Employee( id,name,address,sal) objects and search for particular Employee object based on id number and name.

About

Core Java Assignment Eclipse Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages