Create a class BookData having following members:
private Book book[ ] – Array of type Book
private int index
public void setBook(int bookNo, String title, String publication, String author, float price, String type)
method should create an object at index position starting from 0. public void printBooks( ) – method to print all book details in an array
public String searchByNo ( int bookNo ) – method to return book details of
book whose book no passed as parameter
public String searchByAuthor ( String author ) – method to return all book
names of an author whose name passed as parameter
Create a class Computer derived from Book having following members
private String type - It could be Networking, DataStructure, DBMS
Setter and getter method for type instance variable
Create a class Mathematics derived from Book having following members
private String type – It could be Algebra, Geometry
Setter and getter method for type instance variable
Create a class TestBook having main method. Create an object of Computer. Scan data from user, set and print details of Computer book. Create an object of Mathematics class. Scan data from user, set and print
details of Mathematics book.
Modify the TestBook class in above program. Create an array of Book type of
size 4. Store 2 Computer and 2 Mathematics books data in array and print all
book details.
Create a class with an integer data member. Include functions for input and output in class. Count the number of times each function is called and display it. It should be a user defined program.
Write a program to create a class 'A' with an integer data member. Create another class ' B' with one integer data.
Using friend class do the following,
Write a brief C# script that multiplies the number of recruits by 5 and stores it as the players score. The script should also deduct points when the number of recruits falls below 10 (assuming that the player is part of the team).
Write a statement to draw a rounded rectangle with the following features:
Width = 200 Corner horizontal diameter = 20
Height = 100 Corner vertical diameter = 40
Select the suitable upper-left corner of the rectangle.
Creating a user defined Exception “FileFormatException” by extending IOException as following way
class FileFormatException extends IOException {
public FileFormatException ( ) { }
public FileFormatException ( String gripe ){
super (gripe);
}
}
And using that custom exception as follows:
String readData( BufferReader in ) throws FileFormatException {
…….
while ( ……) {
if ( ch = = -1) // EOF encountered
{
if ( n < len )
throw new FileFormatException ( ) ;
}
………
}
return s ;
}
i) What are the differences between throw and throws? ii) Analyze the above code and write down your comments on whether the procedure is correct ways to use exception or not.
Write a java program that executes three threads. First thread displays Good Morning everyone second. Second thread displays Hello every two seconds and the third thread displays Welcome in every three seconds. Create the three threads by extending the thread class.