Java Lab Assignment
Java Lab Assignment
: CSE 5th Sem Exam 2012 Test: 26.11.2012 Paper Name: Object Technology Lab Semester: Fifth Date of Class Paper Code: CS594D Academic Session: July-Dec 2012
QUESTION PAPER Full Marks:40 Duration: 2hr 1. Write a program, which can run two-thread simultaneously. One thread will calculate the factorial of a number and another thread will calculate the factors of that number. Make sure main thread finishes last. 2. Write a class StringUtil inside package strUtil using default constructor and two overloaded constructor one of which receives a String and prints a String that is the exact reversal of the characters in the first String and another constructor takes two argumentsa string and a number- if the number is a valid, then display the character from the string as specified by that number. Take the inputs from user. 3. Write class Circle using center Point and Point on the circumference. Where Points are objects of the Point class. Point class provides a facility to measure distance between two points. Write a method check(Point p) inside Circle class to check whether the given point is inside or outside the circle. Circle also implements an interface TwoDMeasurement which provides interfaces for getting area and perimeter of the circle. 4. Create four small Java classes; a Driver class that has the main method, a regular java abstract class named Vehicle, then two classes named Car and Truck, respectively that inherit the Vehicle class. Your application needs the following methods1. start(), 2. stop(), 3. turn(), 4. getSpeed(), 5. setSpeed(), 6. increaseSpeed(), 7. decreaseSpeed(), 8. openTrunk(), 9. closeTrunk(), 10. openTailgate(), 11. closeTailgate() In the Car class you must limit the speed to a top speed is 200 km/hr per hour where in Trunk top speed limit is 100 km/hr. The abstract class Vehicle only contains the generic methods, start, stop, getSpeed, etc. The Car class contains the trunk methods and the Truck class contains the tailgate methods. Both Car and Trunk class implements the interface SafeDrive which contains interfaces for checking and generating warring for crossing on road speed limit ( 100 km/hr for Car and 75 km/hr for Truck), if the Trunk/Tailgate is open at the time of start etc. 5. Write classes for implementing two threads t1 and t2, which access a shared Stack. Thread t1 push the values into the stack and t2 pops the values from the same stack. Make sure t1 must not push the value till t2 is popping and t2 must not pop the same value. Write the appropriate methods for these two classes. 6. Write a program in Java, which calculates the total sale amount of each different products ( take at least two product) , profit from each product and total profit for a departmental store inside the package business and where Product class implements the interface Discount to calculate discount on different products and takes user input for purchasing different product.
Page No:
Department of <<CSE>> RCC Institute of Information Technology, Kolkata Canal South Road, Kolkata - 700015 Test No.: CSE 5th Sem Exam 2012 Test: 26.11.2012 Paper Name: Object Technology Lab Semester: Fifth Date of Class Paper Code: CS594D Academic Session: July-Dec 2012
QUESTION PAPER Full Marks:40 Duration: 2hr 7. Create an exception class InvalidInputException which takes an integer( say 10) and prints : InvalidInputException[ 10 ]. Create a class CheckPrime which checks if a given no is prime or not and generate InvaildInputException if inputs are 0, 1 and any negative no. which is derived from a class Number. 8. Create a growable stack depending on user input. Your class will throw an exception if user input exceeds top limit of 50 elements and also throw an exception if any input values are same.
Page No: