0% found this document useful (0 votes)
746 views

Tutorial of OOS With Java

The document contains questions for a tutorial sheet on object-oriented programming concepts. It includes questions on class diagrams, object diagrams, relationships between classes like generalization and aggregation, state diagrams, and data flow diagrams. It also provides code snippets and problems to practice OOP concepts like inheritance, polymorphism, abstract classes, and exception handling.

Uploaded by

CRC PRESS
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
746 views

Tutorial of OOS With Java

The document contains questions for a tutorial sheet on object-oriented programming concepts. It includes questions on class diagrams, object diagrams, relationships between classes like generalization and aggregation, state diagrams, and data flow diagrams. It also provides code snippets and problems to practice OOP concepts like inheritance, polymorphism, abstract classes, and exception handling.

Uploaded by

CRC PRESS
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Krishna Institute of Engineering & Technology

Department of Computer Application


Subject: OOPs
Semester: IV (A)

Tutorial Sheet 1 Q.1. Prepare a class diagram from the instance diagram in following figure.

Q.2. Prepare a class diagram from the instance in following figure. Explain your multiplicity decisions. Each point has an x coordinate and a y coordinate. What is the smallest number of points required to construct a polygon? Does it make a different whether or not a given point may be shared between several polygons? How can you express the fact that point are in a sequence?

Q.3. Consistent with the object diagram that you prepared in Q.No. 2, draw an instance diagram for two triangles with a common side under the following conditions: a. A point belongs to exactly one polygon. b. A point belongs to one or more polygons Q.4. Prepare a class diagram from the instance diagram in following figure. Explain your multiplicity decisions. How does your diagram express the fact that points are in a sequence?

Q.5.Prepare object diagrams showing at least 10 relationships among the following object classes. Include associations. Aggregations and generalizations. Use qualified associations and show multiplicity balls in yours diagrams. You do not need to show attributes or operations. Use association names where needed. As you prepare the diagram, you may add additional object classes. a. School, playground, principal, school, classroom,, book, student, teacher, cafeteria, restroom, computer, desk chair ruler door, swing. Created By: Vipin Kumar Jai Shani Dev

b. Castle, moat, drawbridge, tower, ghost, stairs, dungeon, floor, corridor, room, window, stone, lord, lady, cook. c. Expression, constant, variable, function, argument list, relational operator, term, factor, arithmetic operator, statement program. d. File system, file, directory, file name, ASCII file, executable file, directory file, disk drive, track, sector. e. Automobile, engine, wheel, brake, brake light, door, battery, muffler, tail pipe f. Gas furnace, blower, blower motor, room thermostat, furnace thermostat, humidifier, humidity sensor, gas control, blower control, hot air vents. g. Chess piece, rank, file square, board, move, position, sequence of moves h. Sink, freezer, refrigerator, table, light, switch, window, smoke alarm, burglar alarm, cabinet, bread, cheese, ice, door, kitchen Tutorial Sheet 2 Q.1 Categorize the following relationship into generalization, aggregation, or association. Beware, there may be ternary or n-ary associations in the list so do not assume every relationship involving three or more object classes is a generalization. Defend your answers. a. A country has a capital city. b. A dining philosopher is using a fork. c. A file is an ordinary file or a directory file. d. Files contain records. e. A polygon is composed of an ordered set of points. f. A drawing object is text, a geometrical object, or a group. g. A person uses a computer language on a project. h. Modems and keyboards are input/ output devices. i. Object classes may have several attributes. j. A person plays for a team in a certain year. k. A route connects two cities. l. A student takes a course from a professor. Q.2.Prepare an object diagram for graphical document editor that supports grouping, which is a concept used in a variety of graphical editors. Assume that a document is composed of several sheets. Each sheet contains drawing objects, including text, geometrical objects and groups. A group is simply a set of drawing objects, possibly including other groups. A group must contain at least two drawing objects. A drawing object can be a direct member of at most one group. Geometrical object include circles. ellipses, rectangles. Lines and squares. Q.3. A directory file contains information about files in a directory, including both ordinary files as well as other directory files. Prepare an object diagram which models directory files and ordinary files. Since a directory plus a file name uniquely identifies a file, you will probably want to use file name as qualifier. Q.4. Following figure is a portion of a met model which describes generalization. A generalization is associated with several generalization roles, which are the roles that object classes play in generalization relationships. Role type is either subclass or superclass. Does this model support multiple inheritances? Explain your answer.

Created By: Vipin Kumar

Jai Shani Dev

Generalization Discriminator

Generalization role role type

Object class class name

Q.5. Prepare a portion of an object diagram for a library book checkout system that shows the date a book is due and the late charges for an overdue book as derived objects. Tutorial Sheet 3 Q.1. Write scenarios for the following activities: (a.) Moving a bag of corn, a goose, and a fox across a river in a boat. Only one thing may be carried in the boat at a time. If the goose is left alone with the corn, the corn will be eaten. If the goose is left alone with the fox, the goose will be eaten. Prepare two scenarios, one in which something gets eaten and one in which everything is safely transported across the river. (b.) Getting ready to take a trip in your car. Assume an automatic transmission. Dont forget your seat belt and emergency brake. (c.) An elevator ride to the top floor. (d.) Operation of car cruise control. Include an encounter with show moving traffic that requires you to disengage and then resume control. Q. 2. The direction control for some of the toy electric trains was accomplished by interrupting the power to the train. Prepare state diagram for the headlight and wheels of the train, corresponding to the following scenario. Power is off, train is not moving. Power is turn on, train moves forward and train headlight shines. Power is turn off, train stops and headlight goes out. Power is turn on, headlight shines and train does not move. Power is turn off, headlight goes out. Power is turn on, train runs backward with its headlight shining. Power is turn off, train stops and headlight goes out. Power is turn on, headlight shines and train does not move. Power is turn off, headlight goes out. Power is turn on, train runs forward with its headlight shining. Q.3. A simple digital watch has a display and two buttons to set it, the A button and the B button. The watch has two modes of operation, display time and set time. In the display time mode, hours and minutes are displayed, separated by a flashing colon. The set time mode has two submodes, set hours and set minutes. The A button is used to select modes. Each time it is pressed the modes advances in the sequence: display, set hours, set minutes, display etc. Within the sub modes, the B button is used to advance the hours or minutes once each time it is pressed. Buttons must be released before they can generate another event. Prepare a state diagram of the watch. Q.4. Describe the meaning of the data flow diagram in following figure.

Created By: Vipin Kumar

Jai Shani Dev

Q.5. Prepare a data flow diagram for computing the volume and surface area of a cylinder. Inputs are the height and radius of the cylinder. Output is volume and surface area. Discuss several ways of implementing the data flow diagram. Tutorial Sheet 4 Q.1. Q.2. Q.3. Q4. Q5. Differentiate between the SA / SD methodology and the Jacksons Structured Development methodology with proper illustrations. With the help of proper illustrations differentiate between the concepts of association and aggregation. List the features of the Object Oriented Programming? What are the Object Oriented Languages? List any five such languages along with their specific characteristics. What do you mean by the State Diagram and the Event Trace Scenario? Draw the Event Trace Scenario for a Phone Call and the State Diagram for Phone Line. What do you mean by translation of the object oriented design into an implementation? Discuss the major steps during the translation process. List the Critical Success Factors for the aforesaid translation. Tutorial Sheet 5 What is a constructor? How does it differ from a method? Can we overload constructors? What is the difference between Overloading and Overriding? What is type casting? What are its uses? What are the objects on which casting can be applied? What are arrays? How can values be stored in them? Is it possible to overloaded methods? Explain. a) Static and Final Write down C++ features that are not supported by Java. What is a modifier? Explain the different modifiers used in Java. Jai Shani Dev

Q.1 Q.2 Q.4 Q.5 Q.6 Q.5 Q.6

Created By: Vipin Kumar

Tutorial Sheet 6 Q.1 WAP to create a class named as Bank, which should hold three variables namely Deposit, Withdraw and Balance; all of integer type. The class Bank should inherit the Exception class. Create another class named as Operation, to accept the amount to be withdrawn by the user. If the amount to be withdrawn by the user is greater than the balance amount then a message Invalid Transaction should be printed on the screen. WAP to create an abstract class named as shapes, which contain as abstract method, named as Area. Use this abstract method in classes denoting different kinds of triangles i.e. Right Angled Triangle, Isosceles Triangle, Scalene Triangle and Equilateral Triangle to find out there area. WAP to create a class named as Polygon, which contains a method as compute. The method named as Compute should allow the user to find out each integer angle of any polygon. The Polygon class should also contain a method named as Total to find out the sum of all angles in the polygon. Inherit this class into classes resembling polygons i.e. Pentagon, Hexagon, Heptagon, Octagon, Nonagon and Decagon and calculate the value of each integer angle and the sum of angles. Tutorial Sheet 7 What is multithreading? What is the working of run, start, stop, yield, sleep, wait, suspend, resume, notify, notifyAll, getPriority, setPriority, join, isAlive etc. methods? What is Inter-Threaded Communication? What is dead lock? How threads are scheduled? How they are affected by priorities? What is an applet? And also explain the life cycle of Applet? Tutorial Sheet 8 Q.1 Q.2 Q.3 Q.4 Q.5 Q.6 What do you mean by I/O? What are the differences between reader/writer and input/output stream classes? What is Java-Bean? And differentiate Java-Bean and Enterprise Java Beans? What do you mean by Client/Server Architecture. And how can we establish connection between Client & Server by using Java Programming? What are Servlets? And what is the life cycle of servlet? What do you mean by protocol dependent and protocol independent Servlet?

Q.2

Q.3

Q.1 Q.2 Q.3 Q.4 Q.5 Q.6

Created By: Vipin Kumar

Jai Shani Dev

You might also like