Tutorial Questions For Exams
Tutorial Questions For Exams
Theory Questions
Question 1
You are developing a simple book management system in Java. Each book has attributes like
Author, Title, publicationYear.
(i) Create a package called “Book”
(ii) Import a Scanner class. Briefly explain how compiler locate the class Scanner and what scanner
class is used for.
(iii) Create a Class Book
(iv) Declare the attributes like Author, title, publicationyear as instance variables
(v) Create a method called “displaydetails” and use the method to print out the Book's details.
(vi) Create Second class called "BookManagement" and a main method. Create a new book object
and allocate memory to it.
(vii) Set book attributes using scanner class and display the book details
Question 2
i. Develop a java program to test equality of two numbers
ii. Develop a java program to determine positive or negative number
iii. Develop a java program to determine even or odd numbers
Question 3
iii. Write a java code using a=l* b using two methods (refer to all CAT questions as well)
Question 4
(a) Identify and correct errors in program (refer to CAT questions and coursework)
(b) You are tasked with developing a Car Management System in Java. Each student will
have attributes such as make, model and year. A constructor will be used to initialize the
attributes of the student objects. The system should be flexible enough to create car
objects with different sets of initial information.
(i) Create a car constructor with only a make.
(ii) Create a car constructor with a make and model.
(iii) Write a car constructor with make, model, and year.