class diagram example

134
Consider the class diagram given below. Identify which of the following options best describes the scenario. Options: a) Class B is tightly coupled b) Class B has strong cohesion c) Class B is loosely coupled d) Class B has weak cohesion e) None of the options 1. Consider the following code snippets class Borrower { private String ID; private String Name; public Borrower(String myName, String myID) { ID = myID; Name = myName; } boolean Check_Return_Date( Date_Slip dateSlip, Date today) { return (today.comparedate(dateSlip.get_return_date())); } } 1

Upload: amit-patel

Post on 09-Mar-2015

763 views

Category:

Documents


10 download

TRANSCRIPT

Page 1: Class Diagram Example

Consider the class diagram given below. Identify which of the following options best describes the scenario.

Options:a) Class B is tightly coupled b) Class B has strong cohesionc) Class B is loosely coupledd) Class B has weak cohesione) None of the options

1. Consider the following code snippetsclass Borrower{private String ID;private String Name;public Borrower(String myName, String myID){ ID = myID;Name = myName;}boolean Check_Return_Date( Date_Slip dateSlip, Date today){return (today.comparedate(dateSlip.get_return_date()));}}class LibraryBook {private String name;public ArrayList <Pages> pages = new ArrayList <Pages>();LibraryBook(String name, int pgnumber){this.name = name;

1

Page 2: Class Diagram Example

Pages NP = new Pages(pgnumber);pages.add(NP);}public void addPage(int pageNumber){Pages newPage = new Pages(pageNumber); pages.add(newPage);}}

class Pages{private int pageNumber;private String text ;public Pages(int pageNumber){this.pageNumber = pageNumber;}}class Date_Slip{Date issue_Date;Date return_Date;public Date_Slip(Date idate, Date rdate){issue_Date = idate;return_Date = rdate;}Date get_return_date(){ return return_Date;}}class Date {int day;int month;int year;public Date(int dd, int mm, int yy){ day = dd;month = mm;year = yy;}boolean comparedate(Date newdate){ if (day <= newdate.day && month <= newdate.month && year <= newdate.year)return true;elsereturn false;}}

Identify the relationship between Borrower and Date_Slip

>> Aggregation

2. Which of the following code describes uni-directional association of A towards B?

a.class A{ String title;

b.class A{ String title;

2

Page 3: Class Diagram Example

B my_B; A(){//constructor code; }}class B{ String name; B(){//constructor code; }}

A(){//constructor code; }}class B{ String name; A my_A; B(){//constructor code; }}

c. class A{ String title; A(){//constructor code; }}class B{ String name; B(){//constructor code; }}

d. class A{ String title; A(B my_B){//constructor code; }}class B{ String name; B(){//constructor code; }}

e. class A{ String title; A(){//constructor code; }}class B{ String name; B(A my_A){//constructor code; }}

3. Which of the following code describes bi-directional association of A and B?

a.class A{ String title; B my_B; A(){//constructor code; }}class B{ String name; A my_A; B(){//constructor code; }}

b.class A{ String title; A(){//constructor code; }}class B{ String name; A my_A; B(){//constructor code; }}

c. d.

3

Page 4: Class Diagram Example

class A{ String title; A(){//constructor code; }}class B{ String name; B(){//constructor code; }}

class A{ String title; A(B my_B){//constructor code; }}class B{ String name; B(){//constructor code; }}

e. class A{ String title; A(){//constructor code; }}class B{ String name; B(A my_A){//constructor code; }}

4. Identify the relationship between class A and B from the following code snippet.class A{ String title; A(){//constructor code; }}class B{ String name; B(){//constructor code; }}

a) unidirectional associationb) bidirectional associationc) dependencyd) aggregatione) compositionf) None of these

5. Refer the code snippet given belowclass A{ private int aField; private String sField; A(String sField, int aField) { this.aField=aField; this.sField=sField; }

4

Page 5: Class Diagram Example

public String get_sField() { return sField; }} class B{ private ArrayList <A> aFieldList ; private int bField; B(int bField, String s, int c) { this.bField=bField;

aFieldList = new ArrayList <A>(); aFieldList.add(new A(s,c)); } //other member functions//} Identify the option that most accurately describes relationship exists between class B and class A.

a) Aggregationb) Compositionc) Associationd) unidirectional associatione) bi-directional association

6. A Student can belong to only 1 Section, & a Section can have 1 or more Students. The code which represents this bi-directional association is a.class Section{ private int sectionNo; private int maxNoOfStudents; private Student newStudent; Section(){ //code for constructor } public void addStudent(){ //code to add Students to the arraylist }}class Student{ private String name; private int rollNo; private ArrayList<Section> sections; Student(){ //code for constructor } public void associateSection(){ //code to assign Student to a Section }}

b. class Section{ private int sectionNo; private int maxNoOfStudents; private ArrayList<Student> students; Section(){ //code for constructor } public void addStudent(Student newStudent){ students.add(newStudent); }}class Student{ private String name; private int rollNo; private Section studentSection; Student(){ //code for constructor } public void associateSection(){ //code to assign Student to a Section }}

c. class Section{ private int sectionNo; private int maxNoOfStudents;

d. class Section{ private int sectionNo; private int maxNoOfStudents;

5

Page 6: Class Diagram Example

private ArrayList<Student> students; Section(){ //code for constructor } public void addStudent(Student newStudent){ students.add(newStudent); }}class Student{ private String name; private int rollNo; private ArrayList<Section> studentSections; Student(){ //code for constructor } public void associateSection(){ //code to assign Student to a Section }}

private ArrayList<Student> students; Section(){ Student newStudent = new Student(); // rest of the code } public void addStudent(){ //code to add Students to the arraylist }}class Student{ private String name; private int rollNo; Student(){ //code for constructor } public void associateSection(){ //code to assign Student to a Section }}

e. None of these

7. Which of the following code describes aggregation relationship between A and B?

a.class A{ String title; A(String title){ this.title = title; }}class B{ ArrayList<A> listA; B(){ listA = new ArrayList<A>(); } void addToList(A objA){ listA.add(objA) }}

b.class A{ String title; A(String title){ this.title = title; }}class B{ ArrayList<A> listA; B(ArrayList<A> listOfA){ listA = new ArrayList<A>(); listA = listOfA; } void addToList(A objA){ listA.add(objA) }}

c. class A{ String title; A(String title){ this.title = title; }}class B{ ArrayList<A> listA; B(String s){ listA = new ArrayList<A>();

d. class A{ String title; A(B my_B){//constructor code; }}class B{ String name; B(){//constructor code;

6

Page 7: Class Diagram Example

listA.add(new s); } void addToList(String s){ A objA = new A(s); listA.add(objA) }}

}}

e. None of these

8. Which of the following code describes composition relationship between A and B?

a.class A{ String title; A(String title){ this.title = title; }}class B{ ArrayList<A> listA; B(){ listA = new ArrayList<A>(); } void addToList(A objA){ listA.add(objA) }}

b.class A{ String title; A(String title){ this.title = title; }}class B{ ArrayList<A> listA; B(ArrayList<A> listOfA){ listA = new ArrayList<A>(); listA = listOfA; } void addToList(A objA){ listA.add(objA) }}

c. class A{ String title; A(String title){ this.title = title; }}class B{ ArrayList<A> listA; B(String s){ listA = new ArrayList<A>(); listA.add(new s); } void addToList(String s){ A objA = new A(s); listA.add(objA) }}

d. class A{ String title; A(B my_B){//constructor code; }}class B{ String name; B(){//constructor code; }}

e. None of these

9. Consider the following code and identify the relationship between class A and class B

class Section{ private int sectionNo; private int maxNoOfStudents; private ArrayList<Student> students; Section(){

7

Page 8: Class Diagram Example

//code for constructor } public void addStudent(Student newStudent){ students.add(newStudent); }}class Student{ private String name; private int rollNo; private ArrayList<Section> studentSections; Student(){ //code for constructor } public void associateSection(){ //code to assign Student to a Section }}class graduateStudent extends Student{ private String major; graduateStudent(){

//code for constructor }}

a) Aggregationb) Compositionc) Associationd) Generalizatione) None of these

10. Litware, Inc. creates a new audio player called LitwarePlayer. LitwarePlayer uses a primary file, which uses a newly developed audio format that enables an entire audio CD to be stored in less than 10 kilobytes of memory with no loss of quality. This new primary file type is a media type. Users exchange media files across various platforms and there might be other applications that need to read the LitwarePlayer format.

Identify the relationship between LitwarePlayer and the primary file.a) Associationb) Aggregationc) Compositiond) Dependencye) Generalization

1.The University of Toronto has several departments. Each department is managed by achair, and at least one professor. Professors must be assigned to one, but possibly moredepartments. At least one professor teaches each course, but a professor may be on

8

Page 9: Class Diagram Example

sabbatical and not teach any course. Each course may be taught more than once bydifferent professors. We know of the department name, the professor name, theprofessor employee id, the course names, the course schedule, the term/year that thecourse is taught, the departments the professor is assigned to, the department thatoffers the course.

Identify the class diagram that represents the sceneroi.a)

b)

9

Page 10: Class Diagram Example

c)

10

Page 11: Class Diagram Example

d)

e)

11

Page 12: Class Diagram Example

UML has several relations (association, aggregation and composition) that seem to all mean the same thing : "has a".So, what is the difference between them?

Association represents the ability of one instance to send a message to another instance. This is typically implemented with a pointer or reference instance variable, although it might also be implemented as a method argument, or the creation of a local variable.

[Example:]

|A|----------->|B|

class A{ private: B* itsB;};

Aggregation [...] is the typical whole/part relationship. This is exactly the same as an association with the exception that instances cannot have cyclic aggregation relationships (i.e. a part cannot contain its whole).

[Example:]

12

Page 13: Class Diagram Example

|Node|<>-------->|Node|

class Node{ private: vector<Node*> itsNodes;};

The fact that this is aggregation means that the instances of Node cannot form a cycle. Thus, this is a Tree of Nodes not a graph of Nodes.

Composition [...] is exactly like Aggregation except that the lifetime of the 'part' is controlled by the 'whole'. This control may be direct or transitive. That is, the 'whole' may take direct responsibility for creating or destroying the 'part', or it may accept an already created part, and later pass it on to some other whole that assumes responsibility for it.

[Example:]

|Car|<#>-------->|Carburetor|

class Car{ public: virtual ~Car() {delete itsCarb;} private: Carburetor* itsCarb};

Types of Association:Literal meaning of association means. Being associated with each other means I know you, or you know me right??

Whenever two objects communicate with each other its association relationship.

Association is of different types. Importantly of three types.1. I know u as well as so many other people as well. Same for you. You also know so many people.

This kind of relationship is depicted as simple Association in UML.

This is always characterized by "has a" relationship. Like I have your reference. You have mine reference. Both or none.

2. I am not complete without you. You make me complete. Example a music system consists of sound box, CD player, graphic equalizer etc.

So in other words we may say, a music system is aggregation of CD player, casette player, graphics equalizer, sound box etc.

Or music system object has aggregation relationship with each of the things mentioned above.

3. I am not complete without you. And you dont exist outside me.

13

Page 14: Class Diagram Example

Example could be a tree?

Branches, leaves, fruits dont exists outside it? If tree dies everything dies.

This is strongest form of association and called composition relationship.

Another examples could be relationship between a house and its rooms. Rooms dont exist outside a house? Same room cannot be shared across two houses? And all the rooms persishes if the house collapses.

Categorize the following relationships into inheritance, aggregation, or association. Beware, there may be ternary or n-ary associations in the Iist, so do not assume every relationship involving three or more object classes is an inheritance relationship.

(i) A country has a capital city.(ii) A dining philosopher is using a fork.(iii) A file is an ordinary file or directory file.(iv) Files contain records.(v) A polygon is composed of an ordered set of point(vi) A drawing object is text, a geometrical object,(vii) A person uses a computer language on a project(viii) Modems and keyboards are inputoutput device (ix) Object classes may have several attributes.(x) A person plays for a team in a certain year.(xi) A route connects two cities.(xii) A student takes a course from a professor.(xiii) A student may be a part-time or full-time student.(xiv) An origination has many departments.(xv) A student can undergo many courses simultaneously'.(xvi) You and I are the members of this organization.

1. Consider the following code snippets

class Borrower

{

private String ID;

private String Name;

public Borrower(String myName, String myID)

{

ID = myID;

Name = myName;

}

boolean Check_Return_Date( Date_Slip dateSlip, Date today)

{

14

Page 15: Class Diagram Example

return (today.comparedate(dateSlip.get_return_date()));

}

}

class LibraryBook {

private String name;

public ArrayList <Pages> pages = new ArrayList <Pages>();

LibraryBook(String name, int pgnumber)

{

this.name = name;

Pages NP = new Pages(pgnumber);

pages.add(NP);

}

public void addPage(int pageNumber){

Pages newPage = new Pages(pageNumber);

pages.add(newPage);

}

}

class Pages{

private int pageNumber;

private String text ;

public Pages(int pageNumber){

this.pageNumber = pageNumber;

}

}

class Date_Slip

{

Date issue_Date;

Date return_Date;

public Date_Slip(Date idate, Date rdate)

{

issue_Date = idate;

return_Date = rdate;

}

Date get_return_date()

{

return return_Date;

}

}

class Date {

int day;

int month;

int year;

public Date(int dd, int mm, int yy)

{ day = dd;

15

Page 16: Class Diagram Example

month = mm;

year = yy;

}

boolean comparedate(Date newdate)

{ if (day <= newdate.day && month <= newdate.month && year <= newdate.year)

return true;

else

return false;

}

}

Identify the relationship between Borrower and Date_Slip

2. Which of the following code describes uni-directional association of A towards B?

1.class A{

String title;

B my_B;

A(){

//constructor code;

}

}

class B{

String name;

B(){

//constructor code;

}

}

2.class A{

String title;

A(){

//constructor code;

}

}

class B{

String name;

A my_A;

B(){

//constructor code;

}

}

3.class A{

String title;

A(){

//constructor code;

}

}

class B{

String name;

B(){

//constructor code;

}

}

4.class A{

String title;

A(B my_B){

//constructor code;

}

}

class B{

String name;

B(){

//constructor code;

}

}

16

Page 17: Class Diagram Example

5.class A{

String title;

A(){

//constructor code;

}

}

class B{

String name;

B(A my_A){

//constructor code;

}

}

3. Which of the following code describes bi-directional association of A and B?

1.class A{

String title;

B my_B;

A(){

//constructor code;

}

}

class B{

String name;

A my_A;

B(){

//constructor code;

}

}

2.class A{

String title;

A(){

//constructor code;

}

}

class B{

String name;

A my_A;

B(){

//constructor code;

}

}

3.class A{

String title;

A(){

//constructor code;

}

}

class B{

String name;

B(){

4.class A{

String title;

A(B my_B){

//constructor code;

}

}

class B{

String name;

B(){

17

Page 18: Class Diagram Example

//constructor code;

}

}

//constructor code;

}

}

5.class A{

String title;

A(){

//constructor code;

}

}

class B{

String name;

B(A my_A){

//constructor code;

}

}

4. Identify the relationship between class A and B from the following code snippet.class A{

String title;

A(){

//constructor code;

}

}

class B{

String name;

B(){

//constructor code;

}

}

1. unidirectional association

2. bidirectional association

3. dependency

4. aggregation

5. composition

6. None of these

5. Refer the code snippet given belowclass A

{

private int aField;

private String sField;

18

Page 19: Class Diagram Example

A(String sField, int aField)

{

this.aField=aField;

this.sField=sField;

}

public String get_sField()

{

return sField;

}

}

class B

{

private ArrayList <A> aFieldList ;

private int bField;

B(int bField, String s, int c)

{ this.bField=bField;

aFieldList = new ArrayList <A>();

aFieldList.add(new A(s,c));

}

//other member functions//

}

Identify the option that most accurately describes relationship exists between class B and class A.

1. Aggregation

2. Composition

3. Association

4. unidirectional association

5. bi-directional association

6. A Student can belong to only 1 Section, & a Section can have 1 or more Students. The code

which represents this bi-directional association is

1.class Section{

private int sectionNo;

private int maxNoOfStudents;

private Student newStudent;

Section(){

//code for constructor

}

public void addStudent(){

//code to add Students to the

arraylist

}

}

2.class Section{

private int sectionNo;

private int maxNoOfStudents;

private ArrayList<Student>

students;

Section(){

//code for constructor

}

public void addStudent(Student

newStudent){

students.add(newStudent);

}

19

Page 20: Class Diagram Example

class Student{

private String name;

private int rollNo;

private ArrayList<Section>

sections;

Student(){

//code for constructor

}

public void associateSection(){

//code to assign Student to a

Section

}

}

}

class Student{

private String name;

private int rollNo;

private Section studentSection;

Student(){

//code for constructor

}

public void associateSection(){

//code to assign Student to a

Section

}

}

3.class Section{

private int sectionNo;

private int maxNoOfStudents;

private ArrayList<Student>

students;

Section(){

//code for constructor

}

public void addStudent(Student

newStudent){

students.add(newStudent);

}

}

class Student{

private String name;

private int rollNo;

private ArrayList<Section>

studentSections;

Student(){

//code for constructor

}

public void associateSection(){

//code to assign Student to a

Section

}

}

4.class Section{

private int sectionNo;

private int maxNoOfStudents;

private ArrayList<Student>

students;

Section(){

Student newStudent = new Student();

// rest of the code

}

public void addStudent(){

//code to add Students to the

arraylist

}

}

class Student{

private String name;

private int rollNo;

Student(){

//code for constructor

}

public void associateSection(){

//code to assign Student to a

Section

}

}

5. None of these

20

Page 21: Class Diagram Example

7. Which of the following code describes aggregation relationship between A and B?

1.class A{

String title;

A(String title){

this.title = title;

}

}

class B{

ArrayList<A> listA;

B(){

listA = new ArrayList<A>();

}

void addToList(A objA){

listA.add(objA)

}

}

2.class A{

String title;

A(String title){

this.title = title;

}

}

class B{

ArrayList<A> listA;

B(ArrayList<A> listOfA){

listA = new ArrayList<A>();

listA = listOfA;

}

void addToList(A objA){

listA.add(objA)

}

}

3.class A{

String title;

A(String title){

this.title = title;

}

}

class B{

ArrayList<A> listA;

B(String s){

listA = new ArrayList<A>();

listA.add(new s);

}

void addToList(String s){

A objA = new A(s);

listA.add(objA)

}

}

4.class A{

String title;

A(B my_B){

//constructor code;

}

}

class B{

String name;

B(){

//constructor code;

}

}

5. None of these

8. Which of the following code describes composition relationship between A and B?

21

Page 22: Class Diagram Example

1.class A{

String title;

A(String title){

this.title = title;

}

}

class B{

ArrayList<A> listA;

B(){

listA = new ArrayList<A>();

}

void addToList(A objA){

listA.add(objA)

}

}

2.class A{

String title;

A(String title){

this.title = title;

}

}

class B{

ArrayList<A> listA;

B(ArrayList<A> listOfA){

listA = new ArrayList<A>();

listA = listOfA;

}

void addToList(A objA){

listA.add(objA)

}

}

3.class A{

String title;

A(String title){

this.title = title;

}

}

class B{

ArrayList<A> listA;

B(String s){

listA = new ArrayList<A>();

listA.add(new s);

}

void addToList(String s){

A objA = new A(s);

listA.add(objA)

}

}

4.class A{

String title;

A(B my_B){

//constructor code;

}

}

class B{

String name;

B(){

//constructor code;

}

}

5. None of these

9. Consider the following code and identify the relationship between class A and class B

class Section{

22

Page 23: Class Diagram Example

private int sectionNo;

private int maxNoOfStudents;

private ArrayList<Student> students;

Section(){

//code for constructor

}

public void addStudent(Student newStudent){

students.add(newStudent);

}

}

class Student{

private String name;

private int rollNo;

private ArrayList<Section> studentSections;

Student(){

//code for constructor

}

public void associateSection(){

//code to assign Student to a Section

}

}

class graduateStudent extends Student{

private String major;

graduateStudent(){

//code for constructor

}

}

1. Aggregation

2. Composition

3. Association

4. Generalization

5. None of these

10. Litware, Inc. creates a new audio player called LitwarePlayer. LitwarePlayer uses a primary

file, which uses a newly developed audio format that enables an entire audio CD to be stored

in less than 10 kilobytes of memory with no loss of quality. This new primary file type is a

media type. Users exchange media files across various platforms and there might be other

applications that need to read the LitwarePlayer format.

Identify the relationship between LitwarePlayer and the primary file.

1. Association

2. Aggregation

3. Composition

4. Dependency

5. Generalization

23

Page 24: Class Diagram Example

 

=========================================================

=========================================================

===

1.class complain

{

private String Type;

private String Description;

private Date date_of_registration;

private boolean Status;

public complain(String compType,String compDesc, Date myregistration){

Type = compType;

Description = compDesc;

date_of_registration = myregistration;

Status = false;

}

public complain(String compType,String compDesc, Date myregistration, boolean

comp_Status){

Type = compType;

Description = compDesc;

date_of_registration = myregistration;

Status = comp_Status;

}

private complain(String compType,String compDesc){

Type = compType;

Description = compDesc;

}

public void setStatus(boolean newStatus){

Status = newStatus;

 }

public void getStatus(){

if (Status)

System.out.println("Complaint resolved");

else

System.out.println("Complaint not resolved");

}

public boolean ComplainStatus(){

if (Status)

System.out.println("Complaint resolved");

else

System.out.println("Complaint not resolved");

return Status;

}

24

Page 25: Class Diagram Example

}

class Date

{

int dd;

int mm;

int yy;

Date(int mydd, int mymm, int myyy){ 

dd = mydd;

mm = mymm;

yy = myyy;

}

}

Which of the following statement is invalid.

a) Date D = new Date (30, 10, 2009) 

complain C1 = new complain(“Crime”, “Robbery”, D)

b) Date D = new Date (30, 10, 2009) 

complain C1 = new complain(“Crime”, “Robbery”)

c) Date D = new Date (30, 10, 2009) 

complain C1 = new complain(“Crime”, “Robbery”, D,true)

d) Date D = new Date (30, 10, 2009) 

complain C1 = new complain(“Crime”, “Robbery”, new Date(30,10,2009),true)

e) none of these

2. Following is a class template.

class Address

private String city;

private String country;

private String street;

public Address(String mycity,String mycountry, String mystreet){

city=mycity;

country=mycountry;

street=mystreet;

}

public Address(){

city = "GHT";

country = "INDIA";

street = "M.G Street";

}

public Address(String mycity){

city = mycity;

country = "INDIA";

street = null;

}

public String getCity(){ 

return city;

25

Page 26: Class Diagram Example

}

public String getCountry(){ 

return country;

}

public String getStreet(){ 

return street;

}

}

Identify the expressions that can create a customized Address object.

a) Address A1 = new Address()

b) Address A1 = new Address(“Guwahati”)

c) Address A1 = new Address(“DELHI”, “INDIA”, “PARK STREET”)

d) a,b,c

e) b,c

f) None of the options.

3. A course knows its name , the semester name in which it is offered, the name of the teacher

assigned to teach it, total scores and the pass score.

Identify the code snippet that can be used to create a customized course like named Software

Engineering , offered in the 4th semester , having a total score of 100 , pass score 50 , taught

by Ms Smita who is a senior lecturer in the CS department.

a) 

class course

private String courseName;

private String SemesterName;

private int totalScore;

private int passScore;

private String FacultyName;

public course(String name,String Semester,int totalScore, int passScore, String FacultyName){

courseName = name;

SemesterName = Semester;

this.FacultyName = FacultyName;

this.totalScore = totalScore;

this.passScore = passScore;

}

public String getName(){ 

return courseName;

}

}

b) 

class course

private String courseName;

private String SemesterName;

private int totalScore;

26

Page 27: Class Diagram Example

private int passScore;

private String FacultyName;

public course(String name,String Semester,int totalScore, int passScore, String FacultyName){

courseName = name;

SemesterName = Semester;

FacultyName = FacultyName;

totalScore = totalScore;

passScore = passScore;

}

public String getName(){ 

return courseName;

}

}

c)

class course

private String courseName;

private String SemesterName;

private int totalScore;

private int passScore;

private String FacultyName;

public course(){

courseName = “Software Engineering”;

SemesterName = “4th Semester”;

FacultyName = “Smita”;

totalScore = 100;

passScore = 50;

}

public String getName(){ 

return courseName;

}

}

d) 

class course

{

private String courseName;

private String SemesterName;

private int totalScore;

private int passScore;

private String FacultyName;

public course(String name,String Semester,int cFees){

courseName = name;

SemesterName = Semester;

FacultyName = “Smita”;

totalScore = 100;

27

Page 28: Class Diagram Example

passScore = 50;

}

public String getName(){ 

return courseName;

}

}

e) none of these

4. Seema wants to borrow a book from a library. The library has an automated system. So the

Library displays the main screen, asks Seema to enter her smart

 card and the password. After Seema enters her card and the password, Library verifies the

card and if verification is successful, it asks Seema to enter

 the details of the book she wants to borrow. The library then verifies for the availability of the

book. If the book is available, it asks Seema to go to

 the dispatching counter and collect the book ,otherwise returns a regret note. Library returns

back the card to Seema.

Identify the doing responsibilities of the Library.

a)Library,Seema, Seema’s card.

b)Displaying the main screen, asking for the card, asking for the password, verifying the card,

asking for book details, returning regret note and the card, returning book and the card.

c)Displaying the main screen, asking for the card, asking for the password, verifying the card,

asking for book details, verifying book availability,returning regret note, sending book to the

dispatch counter, asking Seema to collect the book and returning the card.

d)Entering the card, knowing the password, giving the password, knowing the amount, giving

the amount to be withdrawn, giving the book details.

e)card number, password, amount to be withdrawn.

f)none of these.

g)Displaying the main screen, asking for the card, asking for the password, verifying the card,

asking for book details, returning regret note, 

sending book to the dispatch counter, asking Seema to collect the book and returning the card.

5. Mr. Abhishek and Ms. Leela are teaching Computer Science in an engineering college. The

registration number of the college they work in is P01. 

Mr. Abhishek is working as a lecturer and Ms. Leela as laboratory assistant. Each employee of

the college has an employee id, employee name, address and 

category. The college got the registration on 12th June 09 and the end date of the registration

is 11th Jun 10. Mr. Abhishek’s employee id is 78901.

Identify the objects defined in the above scenario.

a)college, Employee, Chemist, Laboratory Assistant.

b)Mr. Abhishek, Ms. Leela, P01, Computer Science

c)Mr. Abhishek, 78901, Ms. Leela, 12th June 09 and 11th June 10

d)Mr. Abhishek, Ms. Leela

e)Mr. Abhishek, Ms. Leela, engineering college

f)None of the options.

28

Page 29: Class Diagram Example

6. IIT Guwahati provides bus services to travel from its campus to the city. Faculties, students,

office staff and visitors can avail this service to travel

 from the city to the IIT campus and vice versa. For those students, faculties and office staff

who are regular traveler, the IIT authority provides travel 

pass on monthly or half yearly basis. A travel pass has a unique pass number and date of

issue. 

Identify the most suitable classes that need to be defined for developing an automated travel

pass management system based on the given scenario. 

a)IIT, Bus, Student, faculty , staff , travel pass

b)Traveler, travel pass, IIT

c)Travel pass , traveler, regular traveler

d)Travel pass , Monthly Travel pass , Half yearly travel pass , traveler

e)Traveler, Half yearly travel pass , Monthly travel pass

7. Mohan is driving his car at a speed of 60k.m/hour. His car is black in color. Mohan can apply

break to decrease the speed of his car and can apply 

accelerator to increase the speed. When he makes a change to the car’s speed he needs to

change the gear.

Which of the following code snippet best define class to be used for creating Mohan’s car?

a) 

class car{

private String color;

private int gear;

private int speed;

public car(String startColor, int startSpeed, int startGear) {

gear = startGear;

color = startColor;

speed = startSpeed;

}

public int getColor() {

return color;

}

public int getGear() {

return gear;

}

public void setGear(int newValue) {

gear = newValue;

}

public int getSpeed() {

return speed;

}

public void applyBrake(int decrement,int newval) {

speed -= decrement;

gear=newval;

}

29

Page 30: Class Diagram Example

public void speedUp(int increment,int newval) {

gear=newval;

}

}

b) class Mohan’s_car {

private String color=”Blue”;

private int gear=2;

private int speed=20;

public int getColor() {

return color;

}

public int getGear() {

return gear;

}

public void setGear(int newValue) {

gear = newValue;

}

public int getSpeed() {

return speed;

}

public void applyBrake(int decrement) {

speed -= decrement;

}

public void speedUp(int increment) {

speed += increment;

}

}

c) class car {

private String color;

private int gear;

private int speed;

public int getColor() {

return color;

}

public void setColor(String newValue){

color = newValue;

}

public int getGear(){

return gear;

}

public void setGear(int newValue){

gear = newValue;

}

public int getSpeed(){

30

Page 31: Class Diagram Example

return speed;

}

public void applyBrake(int decrement){

speed -= decrement;

}

public void speedUp(int increment){

speed += increment;

}

}

d) class car{ 

private String color;

private int gear;

private int speed;

public car(String startColor, int startSpeed, int startGear){

color= startColor;

gear = startGear;

speed = startSpeed;

}

public int getGear(){

return gear;

}

public void setGear(int newValue){

gear = newValue;

}

public int getSpeed(){

return speed;

}

public void applyBrake(int decrement){

speed -= decrement;

}

public void speedUp(int increment) {

speed += increment;

}

}

e) none of these

8. Consider the following code:

class Time{

  private int hour, min, sec;

  public Time(int hour, int min, int sec){

    this.hour=hour;

    this.min=min;

    this.sec=sec;

  }

  public int getHour(){return hour;}

  public int getMinute(){return min;}

31

Page 32: Class Diagram Example

  public int getSecond(){return sec;}

  public Time addminutes(int minutes){

    int newmin = (min + minutes) % 60;

    int newhour = hour + (min + minutes) / 60;

    return new Time(newhour, newmin, sec);

  } 

  public int findDiff(Time T){

    return ((T.getHour() - hour) * 60 + (T.getMinute() - min));

  }

}

class FlightSchedule{

  int duration;

  Time DepartureTime, ArrivalTime;

  public FlightSchedule(){

    this.DepartureTime = new Time(6,0,0);

    this.ArrivalTime = new Time(7,0,0);

    this.duration = 60;

  }

  public FlightSchedule(Time DepTime, int duration){

    this.DepartureTime = DepTime;

    this.duration = duration;

    this.ArrivalTime = DepTime.addminutes(duration);

  }

  public FlightSchedule(Time DepTime, Time ArrTime){

    this.DepartureTime = DepTime;

    this.ArrivalTime = ArrTime;

    this.duration = DepTime.findDiff(ArrTime);

  }

  public FlightSchedule(Time DepTime, Time ArrTime, int duration){

    this.DepartureTime = DepTime;

    this.ArrivalTime = ArrTime;

    this.duration = duration;

  }

}

Using the above code, create a customized object of class FlightSchedule having departure

time as 6:00 am and a flight duration of 150 minutes

a)FlightSchedule FS = new FlightSchedule();

b)FlightSchedule FS = new FlightSchedule(6, 150);

c)FlightSchedule FS = new FlightSchedule(new Time(6,0,0),150);

d)FlightSchedule FS = new FlightSchedule(new Time(6,0,0),new Time(8,30,0));

e)FlightSchedule FS = new FlightSchedule(new Time(6,0,0),new Time(8,30,0), 150);

9. Greyhound Bus Ticket reservation system offers online bus ticket reservation facility. A

customer can register and update his details. For reserving a 

ticket a registered customer has to give his preferences like number of seats, date, source and

destination of journey. Based on seat availability, tickets

32

Page 33: Class Diagram Example

 will be reserved and a booking reference number will be issued. Customer can view the

schedule of the bus by giving his booking reference number. A 

customer can cancel reserved tickets.

From the above scenario, if a system is developed to automate the whole process, what could

be possible business behaviours of an object of type customer?

Book Tickets

Check Availability

Get Customer Preferences

Schedule Arrangement 

Issue PNR

Register Customer

Update Customer Details

Options

a.5,7

b.2, 5, 6

c.3, 7

d.1, 5, 7

e.4,3,1

f.3

10. Govt has deployed a Complaint Tracking system through which the citizens can raise the

complaints against social crimes, bribery all other kind of 

social injustices and also system allows a citizen to check the status of his complaints. Mr X

has registered a complaint and he wishes to check the status of his complaint. Govt

administrator verifies the complaint and transfers the complaint to department in charge.

Identify the messages that need to be passed between the objects Mr X and Complaint

Tracking system in the above scenario.

a)registerComplaint, checkComplaintStatus

b)registerComplaint, checkComplaintStatus,verifyComplaint

c)registerComplaint, verifyComplaint

d)registerComplaint, verifyComplaint,transferComplaint

e)registerComplaint, checkComplaintStatus, verifyComplaint,transferComplaint

f)verifyComplaint,transferComplaint

11. Mrs White wants to enrol her daughter Janet in AllSmart Day Care Centre. Mrs White would

like to know the working hours of AllSmart Day Care Centre. She would also like to know the

charges levied by the AllSmart Day Care Centre. The AllSmart Day Care Centre would like to

know the personal details of Mrs White like her name and address. Janet would like to know

number of swings in the AllSmart Day Care Centre. The AllSmart Day Care Centre would like to

know from Janet, her date of birth and food preferences.

Identify the messages that need to be passed between the objects Mrs White and AllSmart Day

Care Centre in the above scenario.

      

Options:

a)Get working hours, Get charges levied, Get personal details 

b)Get working hours, Get charges levied, Get personal details, Get date of birth

c)Get working hours, Get charges levied, Get personal details, Get food preferences

33

Page 34: Class Diagram Example

d)Get working hours, Get charges levied, Get personal details, Get date of birth, Get food

preferences

e)Get toy available details, Get working hours, Get charges levied, Get personal details, Get

date of birth, Get food preferences

f)None of the options

12. XYZ University had various departments. A professor has to deliver lectures, conduct

evaluations and send evaluation reports. A student has to register for sessions and appear for

evaluations. A student can also see the result of evaluation by using his registration number. 

Exam controller has to schedule evaluation based on availability of professor, and consolidate

all evaluation reports. Lecture duration should be at least 45 minutes. An evaluation should not

be conducted on Fridays. Exam controller should consolidate result within 5 days of exam. A

Professor can send an alert to students informing about registering for sessions, and schedule

of exams.

From the above scenario, if a system is developed to automate the whole process, what could

be possible business behaviours of an object of type professor? 

1.send alert

2.consolidate result

3.schedule evaluation

4.conduct evaluation

5.check availability of professor

6.register student for exam

7.know lecture duration

a.1,7

b.2, 5, 6

c.1, 4

d.1, 5, 7

e.1

f.3

13. An ILP building has 2 floors. Training Room 1 and 2 are in the 1st floor and Training Rooms

3, 4 and 5 are in the 2nd floor of the ILP building. The rooms in the 1st floor have a seat

capacity of 40; where as those in the 2nd floor have a seat capacity of 30 each. Given the

number of ILP participants to a Training Room Object, it can be checked if all the participants

can be accommodated in that training room

Find the attributes of the Training Room class

a)floor, seat capacity, building no

b)floor, seat capacity, training room no

c)floor, seat capacity, training room no, canAccommodateParticipants

d)floor, seat capacity, building no, canAccommodateParticipants

e)floor, seat capacity, training room no, number of ILP participants

14. Read the following scenario and identify the objects.

Mr. X is organizing a dinner party for his friends on 25th of November to celebrate his son’s

birthday. He calls his chef, Mr. Y and tells him to arrange food and drinks for the dinner. He

gives Mr. Y the number of vegetarian and non vegetarian invitees. Mr. Y would also require the

specifications for the drinks he would have to serve as alcoholic and non-alcoholic.

34

Page 35: Class Diagram Example

a)Mr. X, Mr. Y, dinner party, friend, son

b)Organizer, Chef, party, food, drink, specification

c)Mr. X, Mr. Y, dinner party, vegetarian food, non vegetarian food, alcoholic drink, non alcoholic

drink

d)Mr. X, Mr. Y, dinner party, vegetarian food, non vegetarian food, alcoholic drink, non

alcoholic drink, specification

e)Mr. X, Mr. Y, dinner party on 25th November

15. Mr. John arrives at a car showroom. He meets Mr. X, the owner of the showroom. Mr. X

calls the sales representative, Mr. Burns and introduces him to Mr. John. Mr. Burns gets all the

requirements of Mr. John and shows him all the cars in the shop that meets his requirement.

Mr. John asks Mr. Burns about the price of the cars and their specifications. He finally chooses

his desired car and decides to make the payment to Mr. X. Mr. X then asks him if he would be

paying by check or by cash and makes the necessary arrangements.

Identify the messages that need to be passed between the objects Mr John and Mr Burns in the

above scenario

a)show details, get price, get specification, choose car

b)get price, get specification, get payment type

c)get requirement, get price, make payment

d)get requirement, show details, get price, get specification

e)show details, choose car, get payment type, make payment

16. Read the following scenario and identify the objects.

Chandra B, the president of XYZ Manufacturing, requested that Swami V, the MIS department

manager, investigate the viability of selling their products over the Web. Currently, the MIS

department is still using an IBM mainframe as their primary deployment environment. As a first

step, Swami contacted his friends at IBM to see if they had any suggestions as to how XYZ

Manufacturing could move toward supporting sales in an electronic commerce environment

while keeping their mainframe as their main system. His friends explained that IBM now

supports Java and Linux on their mainframes. Furthermore, they suggested that Swami

investigate using object-oriented systems as a basis for developing the new system.

a)Chandra, XYZ Manufacturing, Swami V, MIS Department, product, mainframe, IBM, Java,

Linux

b)Chandra, XYZ Manufacturing, Swami V, product, mainframe

c)Chandra, XYZ Manufacturing, Swami V, MIS Department, IBM, mainframe

d)Chandra, XYZ Manufacturing, Swami V, MIS Department, IBM mainframe, IBM, Java, Linux

e)None of these

17. Consider the following code:

class Box {

  double width;

  double height;

  double depth;

   

  Box(){//constructor 1

    width = 40; height = 40; depth = 40;

  }

  Box(double w, double h, double d) {//constructor 2

35

Page 36: Class Diagram Example

    width = w; height = h; depth = d;

  }

  Box(double w, double h){//constructor 3

    width = w; height=h; depth = h;

  }

  Box(double s){//constructor 4

    width = s; height=s; depth = s;

  }

  // compute and return volume

  double volume() {

    return width * height * depth;

  }

}

Using the above code, create an object of class Box having height, width and depth as 40 cm

a)Box B1 = new Box();

b)Box B1 = new Box(40);

c)Box B1 = new Box(40,40);

d)Box B1 = new Box(40, 40, 40);

e)All of these

18. Read the following scenario and identify the objects.

John’s wife, Heather, and son, Joe, are suffering from cold and having body ache. After a round

of blood test, the doctor confirmed that both of them have got H1N1 virus and are suffering

from Swine Flu. The doctor prescribed some medicine and suggested them to stay at home for

at least 2 weeks. John went to Drugs For You Pharmacy in order to get the prescribed

medicines. The staff at the Pharmacy noted down the doctor name and phone numbers as well

as all the details of the medicine, like medicine manufacturing date, expiry date, batch

number.

Identify the objects involved in the above scenario.

a)John, Heather, Joe, H1N1 virus, Swine Flu, Drugs For You Pharmacy

b)John, Heather, Joe, Drugs For You Pharmacy

c)John, Heather, Joe, H1N1 virus, doctor, Drugs For You Pharmacy

d)John, Heather, Joe, H1N1 virus, Swine Flu, Drugs For You Pharmacy

e)John, Heather, Joe, doctor, prescription, Drugs For You Pharmacy, staff

19. Consider the following code

class Date{

  private int day, month, year;

  public Date(int day, int month, int year){

    this.day = day;

    this.month = month;

    this.year = year;

  }

  public void displayDate(){

    System.out.println(day + ":" + month + ":" + year);

  }

}

36

Page 37: Class Diagram Example

class ConferenceSchedule{

  Date StartDate, FinishDate;

  public ConferenceSchedule (Date D1, Date D2){

    this.StartDate =D1;

    this.FinishDate =D2;

  }

  public Date CalculateDuration(){

    return new Date(FinishDate.day - StartDate.hour, FinishDate.month - StartDate.month,

FinishDate.year - StartDate.year);

  }

}

Find the output when the following code snippet is executed

    Date D1 = new Date(10,2,2009);

    Date D2 = new Date(12,3,2009);

    ConferenceSchedule CS1 = new ConferenceSchedule (D1,D2);

    (CS1.CalculateDuration()).displayDate();

a)2:1:0

b)-2:-1:0

c)Will not be executed since the return type of CalculateDuration() does not match with the

function definition

d)Will not be executed as day, month and year being private, cannot be accessed from objects

of class Date

e)Will not be executed as StartDate and FinishDate are not declared as public.

20. Ashok knows his name, age and hobby. He can show his name, age and his hobby. He/she

celebrates his/her birthday every year. The code snippet for the class used to create Ashok is

defined as follows:

public class Person

{

private String name;

private int age;

private String hobby;

public Person(String nm, int a, String hb)

{

name = nm;

age = a;

hobby=hb;

}

private String getname()

{

return name;

}

private int getage()

{

return age;

}

37

Page 38: Class Diagram Example

public void celebrate_BDAY( int b_day_no)

age=b_day_no;

OOP Exercise Set 1

1. Identify the attributes & methods for a washing machine.Attributes: Width, Height, Length, Weight, Price, CapacityMethods: Wash, Dry, FillWater, DrainWater, SetTimer

2. Assume you are in a market to buy a car, identify the class (es) [Their attributes & methods] relevant in this scenario.

class car{

//Attributesfloat price;float maxSpeed;float mileage;string color;float horsePower;int numberOfGears;boolean airBags;boolean powerWindows;boolean powerSteering;boolean AC;int capacity;

//MethodsmoveForward();moveReverse();turnACOn();turnEngineOn();turnWindowsUp();turnWindowsDown();

}

3. Identify the relationships between the following classes. 1. Library & books in the library - Aggression2. The recipes in a cookbook. - Aggression3. The contents of an encyclopedia - Aggression4. The grammar of FORTRAN - Composition5. The grandparents of the children living in Springfield - Association6. Course & Student - Association7. Book & Chapter - Composition8. Computer & Keyboard - Association9. Team & Person - Aggression10.Remix & Sound Clips - Composition

4. For a Library Management System, Identify the class, responsibility & Identity from the following:

1) Book - Class

38

Page 39: Class Diagram Example

2) Book No - Identity 3) Know Book No - Responsibility 4) Know Title - Responsibility5) Know Purchase Price - Responsibility6) Know Purchased - Responsibility7) Know Date Published - Responsibility8) Know Purchase Date - Responsibility9) Know author - Responsibility

5. Identify classes in the below scenario.

Consider the payroll system that processes employee records at a small manufacturing firm. The company has several classes of employees with particular payroll requirements & rules for processing each. The company has 3 types of employees:

1. Managers receive a regular salary2. Office workers receive an hourly wage & are eligible for overtime after 40 hrs3. Production workers are paid according to a piece rate

CompanyEmployeeManagerOffice WorkersProduction Workers

6. Identify classes in the below scenario.

The gate-keeper at an amusement park is given the following instructions for admitting persons to the park (i) if the person is under three years of age, there is no admission fee. (ii) If a person is under 16, half the full admission fee is charged and this admission is reduced to a quarter of full admission if the person is accompanied by an adult (the reduction applies only if the person is under 12).

Gate-KeeperParkCategory1 visitorCategory2 visitorCategory3 visitor

b. The telephone directory should contain entries for each person in the university community - Student, professor & staff member. Users of the directory can look up entries. In addition, the administrator of the telephone book, can after supplying a password, insert new entries, delete existing entries, modify existing entries, print the telephone book & print a listing of all students or all faculties.

Identify the classes & their operations.Student – Stores a students' informationProfessor – Stores a professors' informationStaff Member – Stores a staff member's informationTelephone Book – Stores telephone entries.

1

39

Page 40: Class Diagram Example

You have to develop an object-oriented drawing application which can be used to draw circles, rectangles, lines, Bezier curves , and many other graphic objects. These objects all have certain states (for exaple position, orientation, line color , fill color) and behaviors ( for example : MoveTo, Rotate, Resize, Draw) in common. Some of these states and behaviors are the same for all graphic objects, e.g position , fill color, and moveTo. Other require different implementations such as resize themselves;they just differ in how they do it. Which Object oriented concept/concepts will you not apply to develop the above mentioned application.Options: a) Abstract class b) Polymorphism c) method overriding d) inheritance e) all of these f) none of these

.2. At ILP Guwahati three batches are there. Every morning at 11 a.m., a special bell rings at the center. The significance of the bell is that, it is the time for all Batch 1 to go to the library, for the batch 2 it is the time to go to the MPH and the batch 3 can go for a break.

Which object oriented concept is related to the fact participant's response to the bell described in the above scenario?

Options:

6. Inheritance7. Polymorphism.8. Composition.9. Encaptulation10. All of these11. None of these.

3.

40

Page 41: Class Diagram Example

To write an efficient code to represent this class hierarchy, which of the following OOP technique can be used?Options:

A.CompositionB.AggregationC.InheritanceD.PolymorphismE.Both b & dF.Both c & d

3.Following is a code snippet class A { float aFieldp; public String PrintName(String aName) { System.out.println(aName); return “My Name”; } public float PrintName() { System.out.println(aField); return aField; }

41

Page 42: Class Diagram Example

}

class M {}

class B extends A { public void PrintName(String astring) { System.out.println("My String"); }} Identify the OOP concept/concepts that are applied in the above code.

Options:

a) Method overridingb) None of thesec)Method overloadingd) Both a& be) Both a & c4. class A{ public void fun1(int x){ System.out.println("int in A"); } public void fun1(int x,int y){

System.out.println("int and int"); }

}

class C { public void fun1(int x){ System.out.println("int in C"); }}

Identify the OOP concept that is/are used in the above code snippet.Options: a) method overloading b) method overriding4 inheritanced) a, b,c

e) none of these

42

Page 43: Class Diagram Example

1.Following is a code snippet.

abstract class Figure { double dim1; double dim2; Figure(double a, double b) { dim1 = a; dim2 = b; }

abstract double area(); public static void main(String args[]) { Rectangle r = new Rectangle(9, 5); Triangle t = new Triangle(10, 8); Figure figref; figref = r; System.out.println("Area is " + figref.area()); figref = t; System.out.println("Area is " + figref.area()); } }

class Rectangle extends Figure { Rectangle(double a, double b) { super(a, b); }

double area() { System.out.println("Inside Area for Rectangle."); return dim1 * dim2; } }

class Triangle extends Figure { Triangle(double a, double b) { super(a, b); }

double area() { System.out.println("Inside Area for Triangle."); return dim1 * dim2 / 2; } }

43

Page 44: Class Diagram Example

Identify the predominant OOP concept that is used.Options:

a) compile time polymorphism b) run time polymorphism

c) method overloadingd).method overriding

1) a2) b3) c4) a & c5) b & d6) a & d

2.Identify the code that represents method overloading

Identify the code that represents method overriding.

a)class student{ int roll; public String name; public student(int r, String nm) { roll = r; name = nm; } public boolean compare(student s) { if (roll == s.roll) return true; else return false; } public int compare(student s, int a) { if (roll == s.roll) return roll; else return a; }}

b)class student{ int roll; public String name; public student(int r, String nm) {

44

Page 45: Class Diagram Example

roll = r; name = nm; } public boolean compare(student s) { if (roll == s.roll) return true; else return false; } public int compare(student s) { if (roll == s.roll) return roll; else return s.roll; }}

c)class student{ int roll; public String name; public student(int r, String nm) { roll = r; name = nm; } public boolean compare(student s) { if (roll == s.roll) return true; else return false; } }class UGStudent extends student{ String major; UGStudent(int r ,String nm,String myMajor) {super (r,nm); major=myMajor; } public boolean compare(student s) { if (roll==s.roll) return true; else return false; }}

45

Page 46: Class Diagram Example

46

Page 47: Class Diagram Example

1. ____________ relationship among the use cases is that it allows you to show optional system behavior.

12. Includes13.Extends14.Generalization15.Uses16.none of these

2. UML is a 2. a language to model syntax 3. an object-oriented development methodology 4. an automatic code generation tool 5. none of the above6. a,b,c

3. What is "the identification of common features (attributes and methods) to form an hierarchy of classes and sub-classes"

a) Abstractionb) Generalizationc) Cohesiond) Data hidinge) Polymorphism

4.

The relationship shown between person and magazine is :

5 Association.6 Aggregation.7 Dependency.8 Generalization.9 None of these

5.

Which of the following is(are) true in the case of an actor in a use case diagram :

1. Must be part of the system.2. Must be a person interacting with the system.3. Maybe a person or another system interacting with the system.

a. (i) & (ii) b. (iii) c. (ii) d. (i)

47

Page 48: Class Diagram Example

6.Consider the below UseCase diagram :

Soda Machine

Supplier’s Representative

Collector

In the above diagram, the Supplier’s Representative puts the soda can inside the soda machine and the Collector collects the money from the soda machine. For performing their actions they both have to unsecure and open the soda machine before perfoming their operations and close it and securing it again after performing their operations.

In order to show the common steps to be perfomed for the operations “Restock” and “Collect” in the UseCase diagram, which of the following stereotypes can be used to eliminate the duplication of steps from the UseCase diagram :

c. Aggregationd. Generalisatione. Inclusionf. extension

48

Restock

Collect

Page 49: Class Diagram Example

7.Suppose an Order Management system exixts with the following uses cases: 1. manage customer details. 2. enter order 3. find customer record and 4. handle invalid product number

Identify the relationships (if any) between the following pairs of use cases.

(i) 1 & 4a. <<extend>>b. <<include>>c. <<uses>>d. None of these

(ii) 2 & 3a. <<extend>>b. <<include>>c. <<uses>>d. None of these

(iii) 1 & 3a. << extend>>b. <<include>>c. <<uses>>d. None of these

(iv) 2 & 4 a. << extend>> b.<<include>>

c.<<uses>>d.None of these

8.Consider the following UseCase diagram and answer the below questions :

49

Page 50: Class Diagram Example

i) State whether the following statement is true or false :

- “’FindEmployeeDetails’ is the base UseCase for the other three UseCases..”

TRUE

ii) The relationship between the UseCase ‘ChangeEmployeeDetails’ and ’FindEmployeeDetails’ :

a. Extension.b. Inclusion.c. None of the above.

7. Raju has to take his mother to the doctor. He drives a car and brings his mother to the doctor. Raju's car rotates four wheels to move the car.

Identify the class diagram that represents the relationship between Raju, his car and wheels.

a)

50

ChangeEmployeeDetails

ViewEmployeeDetails

DeleteEmployeeDetails

FindEmployeeDetails

Manager

Employees’ Personal System

Page 51: Class Diagram Example

b)

c)

51

Page 52: Class Diagram Example

d)

52

Page 53: Class Diagram Example

e)

f) None of the options.g)

53

Page 54: Class Diagram Example

2.

Raju is an instrumentalist. He plays Wind instrument to entertain people. He plays percusion and stringed instruments also to perform on stage. Raju can play wood wind as well as brass wind.

Identify the class diagram that best represents the relationship between Raju, Wind, Percusion and Stringed instruments as described in the above scenerio.

a)

b)

54

Page 55: Class Diagram Example

c)

d)

e)

55

Page 56: Class Diagram Example

f)

56

Page 57: Class Diagram Example

10 An automobile is a type of vehicle. Identify the class diagram that best describe the above scenerio. a)

57

Page 58: Class Diagram Example

b)

c)

d)

58

Page 59: Class Diagram Example

4.

The Online CD ordering system has a single actor: the on-line customer. The customer can browse the catalog, search for a CD, add a CD to the order, view the order details, and place the order. Both "View Order Details" and "Place Order" use "Calculate Order Total".

Identify the use case diagram that represents the Online CD ordering system.

a)

59

Page 60: Class Diagram Example

b)

c)

60

Page 61: Class Diagram Example

d)

e) None of these

61

Page 62: Class Diagram Example

g. A school can have many students. Each student has to take a course but one student can take at most 6 courses. For a course at least there is one student in the school who has taken the course.

Identify the class diagram that represent the above scenario.

h. a)

b)

c)

62

Page 63: Class Diagram Example

d)

63

Page 64: Class Diagram Example

e)

6.Identify the use case diagram that best describes the scenarios Drive Car, Apply Break, Take turn ,take left turn and take right turn.

a)

64

Page 65: Class Diagram Example

b)

c)

65

Page 66: Class Diagram Example

d)

e)

66

Page 67: Class Diagram Example

d. Identify the relation between class AddClip & Channel

class AddClip{ private String name; //rest of attributes of AddClip public void reset(){ // } public void playOn(Channel c){ c.start(); }}class Channel{ private String name; //rest of the attributes of Channel public void tune(){ //code for the implementation } public void start(){ //code for the implementation } public void stop(){ //code for the implementation } public void setFrequency(){ //code for implementation }

67

Page 68: Class Diagram Example

}

17.Association18.Composition19.Dependency20.Aggregations21. Inheritance

Course Id: TP486_ENG-1285029887(study mode)

Course Title: TestPrep 486 Object-Oriented Analysis and Design with UML OMI Link...http://www.ibm.com/developerworks/rational/library/769.html - UML Basics

http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/index.html - Class Diagram

http://www.ibm.com/developerworks/rational/library/3101.html - Sequence Diagram

http://books.google.co.in/books?id=s1sIlw83-pQC&printsec=frontcover&dq=Elements+of+UML+2.0#v=onepage&q=&f=false - The elements of UML 2.0 styleTP486_ENG-1285029887

Design OO

1. What is "the identification of common features (attributes and methods) to form an hierarchy of classes and sub-classes"

a) Abstractionb) Generalizationc) Cohesiond) Data hidinge) Polymorphism

(1 mark)

2.

The diagram above doesn’t depict the correct notation for the relationship if any between Circle and Point.Identify the most appropriate relationship if any between the Circle class and Point class.

68

Circle Point

Page 69: Class Diagram Example

11 Composition12 Generalization13 Aggregation14 None of these (2 marks)

3. The relationship shown between person and magazine is :

e. Association.f. Aggregation.g. Dependency.h. Generalization.

(2 marks)4. The interaction between different objects in a sequence diagram is represented

as ________

f. Datag. Methodsh. Messagesi. Instances

(1 marks)

5. . Identify the synchronous messages from the following sequence diagram

a) manageCourse, createCourseb) manageCourse, assignTutorToCoursec) createCourse, createTopic

69

Page 70: Class Diagram Example

d) createTopic, assignTutorToCoursee) courseID, topicID (2 marks)

6. What is purpose of Sequence diagram?

a) Emphasize the temporal aspect of a scenario b) Emphasize the spatial aspect of a scenario. c) All the above d) None of these

(1 marks)7. Which of the follwing statement is true in sequence Diagram?

a) Horizontal axis represents the passage of time b) Vertical axis represents the objects involved in a sequence c) None of the options d) all of the options

(1 marks)

RA OO8. Which of the following is(are) true in the case of an actor in a use case diagram :

1. Must be part of the system.2. Must be a person interacting with the system.3. Maybe a person or another system interacting with the system.

a. (i) & (ii)b. (iii)c. (ii) d. (i) only

(2 mark)9. Consider the below UseCase diagram :

Soda Machine

Supplier’s Representative

70

Restock

Page 71: Class Diagram Example

Collector

In the above diagram, the Supplier’s Representative puts the soda can inside the soda machine and the Collector collects the money from the soda machine. For performing their actions they both have to unsecure and open the soda machine before perfoming their operations and close it and securing it again after performing their operations.

In order to show the common steps to be perfomed for the operations “Restock” and “Collect” in the UseCase diagram, which of the following stereotypes can be used to eliminate the duplication of steps from the UseCase diagram :

Aggregation Generalisation Inclusion Extension (2 marks)

10. Which of the following is/are true in the case of use cases :

1) A use case can exist without an actor.2) System-level use cases should represent both functional and

non-functional requirements.3) A use case describes the interaction between the system and

one or more actors.4) Use cases provide a basis for performing system tests that

verify that the system works appropriately and validate it.

a. (i) ,(ii) & (iii)b. (ii) & (iii)c. Only (iii)d. (iii) & (iv)e. None of these

Q10) You have a file called docs. Z but do not know what it is. What is the easiest way to look at the contents of the file?a. Use zcat to display its contents.b. Use uncompress to expand the file and then use emacs to display the files contents.c. Copy the file to a floppy disk and uncompress it under Windows.d. Use tar -xt to display the file's contents.Answer: a1 mark

71

Collect

Page 72: Class Diagram Example

Q11) You want to verify which lines in the file kickoff contain 'Bob'. Which of the following commands will accomplish this?a) sed -n /Bob/p kickoffb) sed /Bob/p kickoffc) sed -n 'Bob p' kickoffd) sed /Bob/ kickoff Answer: a1 mark

Q12) You search for the word prize in the file kickoff by typing grep prize kickoff. However you also find lines containing prize as part of a word such as prizes but do not find Prize. How should you change the command to find all occurrences of prize as a word and not part of a word?a) grep -lc prize kickoffb) grep -cw prize kickoffc) grep -vi prize kickoffd) grep -iw prize kickoff Answer: d1 mark

Q13) You want to know how many lines in the kickoff file contains 'prize'. Which of the following commands will produce the desired results?a) grep -n prize kickoffb) grep -c prize kickoffc) grep -v prize kickoffd) grep prize kickoff Answer: b1 mark

Q14) You want to construct a regular expression that will match all lines that end with 'stuff'. Which of the following expressions will do this?a) ^stuffb) stuff$c) $stuffd) stuff^ Answer: b1 mark

Q15) You have an object salaried_employee which has operations like compute_tax and compute_pf. What characteristic of OOPS is followed herea) Polymorphism

72

Page 73: Class Diagram Example

b) Abstractionc) Encapsulationd) HierarchyAnswer b2 marks

Q16) Which characteristic of the Unified process signifies a process of giving a continuous feedback to improve the final product?a) Incrementalb) Iterativec) Architecture-Centricd) Use Case drivenAnswer: b1 mark

Q17) What relationship is shown in the following use case diagram.a) Specializationb) Associationc) Generalizationd) None of the aboveAnswer: c2 marks

Q17) How do you represent a class in a UML?a) Sequence diagramb) Class Diagramc) Use case diagramd) All of the aboveAnswer: b1 mark

73

Page 74: Class Diagram Example

Q19) Choose one out of the following. UML is a ____a) Processb) Methodc) Notationd) None of the aboveAnswer: c1 markQ22) A sequence diagram is: a) a time-line illustrating a typical sequence of calls between object function members b) a call tree illustrating all possible sequences of calls between class function members c) a time-line illustrating the changes in inheritance and instantiation relationships between classes and objects over time d) a tree illustrating inheritance and relationships between classes e) a directed acyclic graph illustrating inheritance and instantiation relationships between classes and objects Answer: a1 mark

Q23) A ____________ exists between two defined elements if a change to the definition of one would result in a change to the othera) Dependencyb) Multiplicityc) Realizationd) GeneralizationAnswer: a1 mark

Q24) Which characteristic of the Unified process signifies a process of giving a continuous feedback to improve the final product?a) Incrementalb) Iterativec) Architecture-Centricd) Use Case drivenAnswer: b2 marks

Q25)

74

Page 75: Class Diagram Example

Which of the following statements is bug?a) ddd is an attributeb) iii is a classc) mmm is a methodd) ppp is a methode) hhh is a classAnswer: a, c and e3 marks

Q11) You know that the info utility provides easier to understand documentation but you have never used it. How can you access a tutorial on using info?a. man infob. infoc. info infod. info helpAnswer: a and b2 marks

Q12) You want to know how much space is being occupied by your user's home directories. Which of the following will provide you with this information?a. du -l /homeb. du -b /homec. du -m /homed. du -c /homeAnswer: d1 mark

Q13) What should you type to change the runlevel of your system?a. init [runlevel]b. halt [runlevel]c. /etc/inittabd. sys init [runlevel] Answer: a1 mark

75

Page 76: Class Diagram Example

Q14) Where are the startup scripts defined?a. /etc/initdb. /etc/scriptsc. /etc/startd. /etc/inittabAnswer: d1 mark

Q15) You are going to install a new hard disk in your system. Which of the following commands will halt your system so you can install the new hardware?a) shutdown -k nowb) shutdown -h nowc) shutdown -r nowd) shutdown -t nowAnswer: b

1 mark

Q16)

Which one of the following statements is false:-a) aaa and hhh are linked by a gen-spec relationshipb) sss is a method of hhhc) hhh is a specialisation of aaad) ooo and hhh are linked by a whole-part relationshipe) bbb is an attribute of hhhAnswer: b and e3 marks

Q17) When does a bug in a program result?a) Program built under unsafe environmentb) Program not neatc) There are errors in logic, code and designd) All the aboveAnswer: c1 mark

76

Page 77: Class Diagram Example

Unix:

Q31) You have a file called docs.Z but do not know what it is.

What is the easiest way to look at the contents of the file?a. Use zcat to display its contents.b. Use uncompress to expand the file and then use emacs to display the files contents.c. Copy the file to a floppy disk and uncompress it under Windows.d. Use tar -xt to display the file's contents.Answer: a

Q32) You want to verify which lines in the file kickoff contain

'Bob'. Which of the following commands will accomplish this?a. sed -n /Bob/p kickoffb. sed /Bob/p kickoffc. sed -n 'Bob p' kickoffd. sed /Bob/ kickoff Answer: a

Q33) You search for the word prize in the file kickoff by typing

grep prize kickoff. However you also find lines containing prize

as part of a word such as prizes but do not find Prize. How

should you change the commandto find all occurrences of prize as

a word and not part of a word?a. grep -lc prize kickoffb. grep -cw prize kickoffc. grep -vi prize kickoffd. grep -iw prize kickoff Answer: d

Q34) You want to know how many lines in the kickoff file

contains 'prize'. Which of the following commands will produce

the desired results?a. grep -n prize kickoffb. grep -c prize kickoffc. grep -v prize kickoff

77

Page 78: Class Diagram Example

d. grep prize kickoff Answer: b

Q35) You want to construct a regular expression that will match

all lines that end with 'stuff'. Which of the following

expressions will do this?a. ^stuffb. stuff$c. $stuffd. stuff^ Answer: b

Q36) You know that the info utility provides easier to

understand documentation but you have never used it. How can you

access a tutorial on using info?a. man infob. infoc. info infod. info helpAnswer: a and b

Q37) You want to know how much space is being occupied by your

user's home directories. Which of the following will provide you

with this information?a. du -l /homeb. du -b /homec. du -m /homed. du -c /homeAnswer: d

Q38) What should you type to change the runlevel of your system?a. init [runlevel]b. halt [runlevel]c. /etc/inittabd. sys init [runlevel] Answer: a

Q39) Where are the startup scripts defined?a. /etc/initdb. /etc/scripts

78

Page 79: Class Diagram Example

c. /etc/startd. /etc/inittabAnswer: d

Q40) You are going to install a new hard disk in your system.

Which of the following commands will halt your system so you can

install the new hardware?a. shutdown -k nowb. shutdown -h nowc. shutdown -r nowd. shutdown -t nowAnswer: b

Use Case Diagram:

Q41) You have an object salaried_employee which has operations like compute_tax and compute_pf. What characteristic of OOPS is followed herea) Polymorphismb) Abstractionc) Encapsulationd) HierarchyAnswer b2 marks

Q42) Which characteristic of the Unified process signifies a process of giving a continuous feedback to improve the final product?a) Incrementalb) Iterativec) Architecture-Centricd) Use Case drivenAnswer: b2 marks

Q43) What relationship is shown in the follwoing use case diagram.a) Specializationb) Associationc) Generalizationd) None of the aboveAnswer: c2 marks

79

Page 80: Class Diagram Example

Q44) How do you represent a class in a UML?a) Sequence diagramb) Class Diagramc) Use case diagramd) All of the aboveAnswer: b1 mark

Q45) Choose one out of the following. UML is a ____a) Processb) Methodc) Notationd) None of the aboveAnswer: c1 mark

Q46) ____________ takes an external perspective of the testobject to derive test cases. These tests can be functional or non-functional, though usually functional. The test designer selects valid and invalid input and determines the correct output. There is no knowledge of the test object's internal structure.a) Black box testingb) White box testingAnswer: a2 marks

Q47) Which of the following is not a tool for designing modular systemsa) Structure chartsb) Data dictionariesc) Class diagramsd) Collaboration diagramsAnswer: b2 marks

Q48) A sequence diagram is:

80

Page 81: Class Diagram Example

a) a time-line illustrating a typical sequence of calls between object function members b) a call tree illustrating all possible sequences of calls between class function members c) a time-line illustrating the changes in inheritance and instantiation relationships between classes and objects over time d) a tree illustrating inheritance and relationships between classes e) a directed acyclic graph illustrating inheritance and instantiation relationships between classes and objects Answer: a1 mark

Q49) A ____________ exists between two defined elements if a change to the definition of one would result in a change to the othera) Dependencyb) Multiplicityc) Realizationd) GeneralizationAnswer: a1 mark

Q50)

Which of the following statements is false:a) ddd is an attributeb) iii is a classc) mmm is a methodd) ppp is a methode) hhh is a class

Answer: a, c and e2 marks

Q51) Which one of the following statements is false:-a) aaa and hhh are linked by a gen-spec relationshipb) sss is a method of hhhc) hhh is a specialisation of aaad) ooo and hhh are linked by a whole-part relationship

81

Page 82: Class Diagram Example

e) bbb is an attribute of hhh

Q52) Which one of the following statements is false:-a) ooo and hhh are linked by a whole-part relationshipb) hhh is a specialisation of aaac) sss is a method of hhhd) bbb is an attribute of hhhe) aaa and hhh are linked by a gen-spec relationship

Q53) What is the difference between activity and sequence diagram?

a) Using Sequence diagram it can be shown how processes execute in sequence; for example what operations are

called in what order and what parameter. While using Activity diagram operational workflows can be shown.b) Actors cannot be created in sequence diagram as interactions may not contain actors.c) Both are samed) (a) and (b)2 marksUse Case Questions

1. Which statements are true for an Actor?a) an actor is a role a user plays with respect to the systemb) generalization is not applicable to actorsc) an actor does not need to be human. A subsystem or external system can be

modelled as an actord) a and ce) b and c

(Easy)

2. Which statements are true for an Actor?

82

Page 83: Class Diagram Example

The diagram above doesn’t depict the correct notation between the use cases Enroll Student - Enroll In SeminarEnroll International Student - Enroll Student

Identify the most appropriate relationship between the use cases“Enroll International Student” and “Enroll Student”.

a) <<include>>b) <<extend>>c) <<uses>>d) None of the above

(Complex)

3. Identify the most appropriate relationship between the use cases“Enroll Student” and “Enroll In Seminar”.

a) <<include>>b) <<extend>>c) <<uses>>d) None of the above

(Complex)

4. Which are valid relationships in Use Case Diagrams?a) includeb) extractc) subtypingd) generalization

(Moderate)

Class Diagram Questions

83

InternationalStudent

Student

Enroll Student

Enroll International Student

Enroll in Seminar

Page 84: Class Diagram Example

5. Which relationships in Class diagram shows inheritance relationships?

a) Aggregationb) Compositionc) Specializationd) Association

(Easy)

6.

The diagram above doesn’t depict the correct notation for the relationship if any between Customer and Order.Identify the most appropriate relationship if any between the Circle class and Point class.

a) Generalizationb) Aggregationc) Associationd) None of these

(Easy)

7.

The diagram above doesn’t depict the correct notation for the relationship if any between Customer and Order.Identify the most appropriate relationship if any between the Circle class and Point class.

a) Generalizationb) Aggregationc) Associationd) None of these

(Easy)

8. Aggregation (encapsulation) relationships are represented in the UML notation by:

a) Nesting of classesb) lines with a solid diamond at one endc) lines with a hollow diamond at one endd) lines with an arrow at one ende) lines without an arrow at either end

(Easy)

9. Inheritance relationships are represented in the UML notation by :

84

Customer Order

Car Wheel

Page 85: Class Diagram Example

a) Nesting of classesb) lines with a solid diamond at one endc) lines with a hollow diamond at one endd) lines with a triangular arrow at one ende) lines with a triangular arrow at both ends

(Easy)10.What is the association multiplicity indicator for "zero or more" in

UML notation? Select the correct answer:a) 0->*b) *..0c) 0..*d) 0->more

(Easy)

Sequence Diagram Questions

11.getID() belongs to which class, in the below diagram?

a) Both A & Bb) Both C & Bc) Only Cd) A, B & C

(Moderate)

12.Identify which all the statement(s) is(are) true.

a) Sequence diagrams emphasize the temporal aspect of a scenario.b) Collaboration diagrams emphasize the spatial aspect of a scenario.c) Both Sequence diagrams and Collaboration diagrams represents the types of

Interactions diagrams.d) All of the above (a , b & c)e) Only a & b

(Easy)

13.Can we show the return type of message call in sequence diagram?a) Yesb) No

(Easy)

85

:A :B

getID()

:C

getID()

Page 86: Class Diagram Example

14.Which of the following notation is true about visibility in sequence diagram?

a) + is used for public element.b) = is used for private elementc) * is used for private elementd) - is used for public element

(Easy)

15.Sequence diagrama) interaction between objects by message passingb) Specifies the behavior of a system or a part of a system.c) Specification of a communicationd) All of the above

16.In the given diagram, Update() is not present in UI class?a) Trueb) False

(Hard)

17.In the given diagram, Enterdetails () is not present in UI class?a) Trueb) False

(Hard)

18.In the given diagram, update-employee () is present in which class?

86

:UI : Employee details

Enterdetails()

update-employee()

getEmployeeid()

(If valid employee id) Savedetails()

Confirmation

Alt

Update()

Page 87: Class Diagram Example

a) UIb) Employee Details

(Moderate)

8. Raju has to take his mother to the doctor. He drives a car and brings his mother to the doctor. Raju's car rotates four wheels to move the car.

Identify the class diagram that represents the relationship between Raju, his car and wheels.

a)

b)

c)

87

Page 88: Class Diagram Example

d)

e)

88

Page 89: Class Diagram Example

f) None of the options.g)

2.

Raju is an instrumentalist. He plays Wind instrument to entertain people. He plays percusion and stringed instruments also to perform on stage. Raju can play wood wind as well as brass wind.

Identify the class diagram that best represents the relationship between Raju, Wind, Percusion and Stringed instruments as described in the above scenerio.

89

Page 90: Class Diagram Example

a)

b)

c)

d)

90

Page 91: Class Diagram Example

e)

91

Page 92: Class Diagram Example

f)

15 An automobile is a type of vehicle. Identify the class diagram that best describe the above scenerio. a)

b)

92

Page 93: Class Diagram Example

c)

d)

4.

The Online CD ordering system has a single actor: the on-line customer. The customer can browse the catalog, search for a CD, add a CD to the order, view the order details, and place the order. Both "View Order Details" and "Place Order" use "Calculate Order Total".

Identify the use case diagram that represents the Online CD ordering system.

a)

93

Page 94: Class Diagram Example

b)

c)

94

Page 95: Class Diagram Example

d)

e) None of these

i. A school can have many students. Each student has to take a course but one

95

Page 96: Class Diagram Example

student can take at most 6 courses. For a course at least there is one student in the school who has taken the course.

Identify the class diagram that represent the above scenario.

j. a)

b)

c)

96

Page 97: Class Diagram Example

d)

e)

97

Page 98: Class Diagram Example

2. Identify the use case diagram that best describes the scenarios Drive Car, Apply Break, Take turn ,take left turn and take right turn.

a)

b)

98

Page 99: Class Diagram Example

c)

d)

e)

99

Page 100: Class Diagram Example

i. Identify the relation between class AddClip & Channel

class AddClip{ private String name; //rest of attributes of AddClip public void reset(){ // } public void playOn(Channel c){ c.start(); }}class Channel{ private String name; //rest of the attributes of Channel public void tune(){ //code for the implementation } public void start(){ //code for the implementation } public void stop(){ //code for the implementation } public void setFrequency(){ //code for implementation }}

22. Association23. Composition24. Dependency25. Aggregation

100

Page 101: Class Diagram Example

26. Inheritance

Design OO

1. What is "the identification of common features (attributes and methods) to form an hierarchy of classes and sub-classes"

a) Abstractionb) Generalizationc) Cohesiond) Data hidinge) Polymorphism

(1 mark)

2.

The diagram above doesn’t depict the correct notation for the relationship if any between Circle and Point.Identify the most appropriate relationship if any between the Circle class and Point class.

16 Composition17 Generalization18 Aggregation19 None of these (2 marks)

3. The relationship shown between person and magazine is :

j. Association.k. Aggregation.l. Dependency.m. Generalization.

(2 marks)4. The interaction between different objects in a sequence diagram is represented

as ________

j. Datak. Methodsl. Messagesm. Instances

(1 marks)

101

Circle Point

Page 102: Class Diagram Example

5. . Identify the synchronous messages from the following sequence diagram

f) manageCourse, createCourseg) manageCourse, assignTutorToCourseh) createCourse, createTopici) createTopic, assignTutorToCoursej) courseID, topicID (2 marks)

6. What is purpose of Sequence diagram?

a) Emphasize the temporal aspect of a scenario b) Emphasize the spatial aspect of a scenario. c) All the above d) None of these

(1 marks)7. Which of the follwing statement is true in sequence Diagram?

a) Horizontal axis represents the passage of time b) Vertical axis represents the objects involved in a sequence c) None of the options d) all of the options

(1 marks)

RA OO8. Which of the following is(are) true in the case of an actor in a use case diagram :

4. Must be part of the system.5. Must be a person interacting with the system.6. Maybe a person or another system interacting with the system.

102

Page 103: Class Diagram Example

e. (i) & (ii)f. (iii)g. (ii) h. (i) only

(2 mark)9. Consider the below UseCase diagram :

Soda Machine

Supplier’s Representative

Collector

In the above diagram, the Supplier’s Representative puts the soda can inside the soda machine and the Collector collects the money from the soda machine. For performing their actions they both have to unsecure and open the soda machine before perfoming their operations and close it and securing it again after performing their operations.

In order to show the common steps to be perfomed for the operations “Restock” and “Collect” in the UseCase diagram, which of the following stereotypes can be used to eliminate the duplication of steps from the UseCase diagram :

Aggregation Generalisation Inclusion Extension (2 marks)

10. Which of the following is/are true in the case of use cases :

1) A use case can exist without an actor.2) System-level use cases should represent both functional and

non-functional requirements.3) A use case describes the interaction between the system and

one or more actors.

103

Restock

Collect

Page 104: Class Diagram Example

4) Use cases provide a basis for performing system tests that verify that the system works appropriately and validate it.

f. (i) ,(ii) & (iii)g. (ii) & (iii)h. Only (iii)i. (iii) & (iv)j. None of these

(1 mark)RA Structured

11.

k. An invoice must have one Purchase order and purchase order may or may not have

many invoices.

l. An invoice has one purchase order and purchase order have many invoices.

m. An invoice has must one purchase order and purchase order must have one or more

invoices.

n. A purchase order must have an invoice and an invoice amy or maynot have

purchase orde

12. Which one is correct?

1.

104

Page 105: Class Diagram Example

2.

3.

4.

( 1 mark)13. Identify the inappropriate entities in ERD of ABC Banking system shown below.

105

Page 106: Class Diagram Example

Treasurer is the user of the ABC banking system. Treasurer manages the Database of the ABC Bank. Treasurer also receives the expense report which is nothing but a consolidated expense charged for an account.

- Treasurer- Expense Report- Account- Expense- I and ii

( 2 marks)

106

Page 107: Class Diagram Example

14.

. Choose the error in the DFD above if any i) P1 cannot be in a loop ii) No error iii) P1 cannot write to 2 data store iv) Output from P1 is same and cannot be written to two different data store

1. I and iii2. Ii3. I and iv4. Iii and iv ( 2 marks)

15. In DFD open-ended rectangles representing____________ including electronic stores such as databases or XML files and physical stores such as or filing cabinets or stacks of paper.

i. data flows

ii entities.

iii. processes

iv. data stores

( 1 mark)

Design Structured

107

M1

P1 Update Account

C Customer M

Account Details

Account details

Customer Details

Customer Details

Page 108: Class Diagram Example

16. Normalize the table to 3NF

R1

f. PackaingNote{NoteNo,Packer,Name}g. CustomerDeatails{Name,Address}h. PackingNoteItem(NoteNo,ItemNo,Qty,PartNo)i. Part (PartNo,Desc)

5) PackaingPart(NoteNo,ItemNo,Qty,PartNo,Desc) 6) Packer(NoteNo,Packer,Name,Address)a) 1,2,3,4b) 1,3,4,5c) 1,2, 5d) 5,6 ( 3 marks)17. Choose the statements which state the benefit of Structure Chart

5. Sequential ordering of the modules6. Data interchange among modules7. Procedural implementation of the modules8. Various modules that represent the system.

1.I only2.I, ii and iv3.Ii and iv4.Iii and iv5.None of the above ( 2 marks)

17. Arrows with filled circles in Structure chart represent

i) Data passing among different modules27. call from lower module to high level modules28. control flag flow between modules29. shows iteration ( 1 mark)(iv) For converting a given table to 1 NF we need to

a. Remove the repeating groupsb. Remove partial dependenciesc. Remove transitional dependenciesd. All the above ( 1 mark)

19.

108

NoteNo Packer Name Address ItemNo Qty PartNo Desc300 Jony Bloggs Chennai 1 120 1234 Nuts300 Jony Bloggs Chennai 2 200 3000 Bolts300 Jony Bloggs Chennai 3 300 3321 Washer

Page 109: Class Diagram Example

Assuming that the entity types have the following attributes:   Course(course_no, c_name), Student(matric_no, st_name, dob).

Choose the set of relations tht are produced after mapping the ERD to relations

Course(course no, c_nema) and Student(matric_no, st_name, dob, course_no)

n. Matriculate (course no, matric_no, c_nema)o. Matriculate (course no, matric_no, c_nema, st_name, dob)p. Course(course no, c_nema, matric_no) and Student(matric_no, st_name,dob)q. None of these.

20.

Assuming that the entity types have the following attributes:   Student(matric_no, st_name, dob), Module(module_no, m_name, level, credits) Choose the correct set of relations that are produced after mapping the ERD to relations

3. Student(matric_no, st_name, dob),Module(module_no, m_name, level, credits), Studies(matric_no,module_no)

4. Student(matric_no, st_name, dob, module_no)5. Module(module_no, m_name, level, credits,matric_no)6. None of these.7. Either (a) or (b) or (c)

Marks 321. checking for 3NF consists of a) there are no no-atomic attributes in the relation b) degree of the relation c) checking that all attributes in the relation depends on the primary key. d) checking for a situation where an attribute is in the relation but that attribute is better defined by some other attribute that is not the primary key. e) a , c , d f) a , b , c Marks 122.Which of the following are true with respect to normalization: a) Normalization is the process of efficiently organizing data in a database. b) Goal of normalization is eliminating redundant data . c) It reduce the amount of space a database consumes. d) All of these. e) None of these. Marks 223. To bring a relation to 1 NF

109

Page 110: Class Diagram Example

a) Eliminate duplicative columns from the same table. b) Create separate tables for each group of related data and identify each row with a unique column or set of columns. c)Remove subsets of data that apply to multiple rows of a table and place them in separate tables. d) a & c e) a & b

24 CUSTOMER table is as follows:

CUSTID CUSTNAME DESIGNATION HOUSENO STREET CITY ZIPC1011 Mr. Mohan LDA G45 M.G

StreetDelhi 320001

C1001 Mrs. Shahsi

UD H16 K.K Street

Delhi 320001

C2010 Mr. Barua LDA A09 M.L Street

GHT 781001

C3300 Mr. Dutta LDA C10 P.K Street

GHT 781001

In which normal form the table is9. Unnormalized10. Second normal form11. First normal form12. Third normal form13. Fourth normal form.

Marks 323.The unnormalized relation ORDERFROM is given as ORDERFROM (Order No, Order Date, Customer No, Customer Name, Product No, Product Description, Qty Ordered ) . After decomposition the following relations are formedORDERFROM ( Order No, Order Date, Customer No, Customer Name ), ORDERLINE ( Order No, Product No, Product Description, Qty Ordered ),PRODUCT (Product No, Product Description), Which of the following are in 1NF a) ORDERFROM b) ORDERLINE c) PRODUCT d) b & c e) a, b &c

1.SriLankan Holidays , the leisure arm of SriLankan Airlines invites Indian kids to a holiday Sri Lanka. On offer are four exciting tours, Holiday in Colombo, Holiday on the Beach,Holiday in Negombo and Holiday in Kandy. A minimum of two adults purchasing the package entitles a maximum of two children below the age of 12 to these holiday packages. These special packages include return airfare on SriLankan Airlines including Fuel Surcharge for adult tickets, accommodation

110

Page 111: Class Diagram Example

on Bed & Breakfast basis, airport and internal transfers, transportation by air-conditioned vehicle and English speaking chauffeur guide with a city tour of Colombo. Unbeatable travel deals have become the trademark of SriLankan Holidays which works with a global network of hotels and tour operators to offer holidaymakers excellent value-for-money travel packages in the airline's destinations. These range from leisure travel for individuals, couples and families, to business travel, adventure travel, sports tourism, cultural tours, and MICE tourism(Meeting, Incentives, Conventions and Exhibitions) Identify the classes from the above depicted scenario.

Options:

a) Kid, SriLankan Holidays, SriLankan Airlines,Travel,Tour, Package b) Tour,Package,Ticket,Holiday makerc) Tour, Package,Ticket, Fuel Surcharge,Accommodation, internal transfer,vehicle, Guide, Holidaymakerd) Kid , Parent,Tour,Package, Ticket,Airline e) Kid, Parent, Airline,Holiday, Package, Tour,Holiday maker

Ayur the pioneer brand in the Herbal cosmetic market launched its new range of natural colour cosmetics, under the brand name “WOMSEE”. The products are made of pure herbs without any harmful chemical ingredients. Mr. Dilvinder Singh Narang, Managing Director, Ayur Herbal Cosmetics said, “We are delighted to introduce a new brand of natural colour cosmetic to our consumers.” There will be six different ranges of products under “WOMSEE” namely Foundation, Compact, Thirty six shades of lipsticks, Twelve shades of Lip glosses, Mascara and Eye-Liners. Identify the objects from the above scenario.

Options:a) Ayur, Mr. Dilvinder Singh Narangb)Ayur, WOMSEE, Mr. Dilvinder Singh Narangc)Ayur,WOMSEE, Mr. Dilvinder Singh Narang,Foundation, Compact, Lipstick,Lip gloss, Mascara, Eye-Linerd) Ayur, Mr. Dilvinder Singh Narang,Foundation, Compact, Lipstick,Lip gloss, Mascara, Eye-Linere) WOMSEE, Mr. Dilvinder Singh Narang

Mrs Hldar is very expert in making cakes and cookies. She makes Blueberry Cheese Cake for her son's birthday. The ingredients required to prepare Blueberry Cheese Cake are 200 gm Blueberry, 3 Egg yolk, 50 gm sugar, 250 gm cheese, 500 gm rich cream,20 gm gelatin and 200gm sponge vanilla. Mrs Halder is going to follow the recipe by Sarita

111

Page 112: Class Diagram Example

Dalal. To make the cake, she adds sugar and egg yolks in a bowl and whisk it until if becomes fluffy. To that mixture, cheese, cream, and Blueberry are added. For the base of the cake, a cake tin is lined with vanilla sponge. The gelatin mixed with warm water is added to the main mixture and spread evenly on the base which is then refrigerated for a couple of hours. Identify the relationship between the Blueberry cake and its ingredients.

Options:

a) compositionb) aggregationc) dependencyd) inheritancee) none of these

A company produces products like shampoo, bathing soap and biscuits. The revenue generated by the company is increased this year over the last year. The revenue generated by shampoo is increased by 50%, by bath soap is 30% and by biscuit is 20%. The code written to calculate the revenue generated by each of the products are give as below.

abstract class product{ public String product_code; public String product_description; public double unit_price; public product(String p_code,String description, double price) { product_code=p_code; product_description = description; unit_price= price; } public abstract double FindRevenue(double last_revenue);}class Soap extends product{ private String flavour; public Soap(String myflavour,String p_code,String description,Double price) { super(p_code,description,price); flavour=myflavour; } public double FindRevenue(double last_revenue) { return (last_revenue + last_revenue * .3); }}

112

Page 113: Class Diagram Example

class Shampoo extends product{ private String flavour; public Shampoo(String myflavour,String p_code,String description, double price) { super(p_code,description,price); flavour=myflavour; } public double FindRevenue(double last_revenue) { return (last_revenue + last_revenue * .5); }}class Biscuit extends product{ public Biscuit(String p_code,String description, double price) { super(p_code,description,price); } public double FindRevenue(double last_revenue) { return (last_revenue + last_revenue * .2); }}

Identify the OOP concept that is/are applied.Option:

a) method overridingb) method overloadingc) associationd) all of thesee) none of these

There are ten animals ---two each lions, panthers, bisons, bears, and deer---in a zoo. The enclosures in the zoo are named X,Y,Z,P and Q and each enclosure is allotted to one of the following attendants,Jack,Mohan, Shalini, Suman and Rita. Two animals of different species are housed in each enclosure. Identify the classes from the above depicted scenario.

Options:a) lion,panther , bison, bear,deer,Mohan ,Shalini, Suman ,Rita,X,Y,Z,P and Qb) animal,species,loin,panther,bison,bear,enclosure,attendantc) Animal,loin,panther,bison,bear,enclosure,attendant

113

Page 114: Class Diagram Example

d) lion , panther,boson,deer,enclosure,attendante) Animal,enclosure, attendant.

A bus of Haryana road which costs Rs. 7,20,000 to the government make a trip to and from Hisar to Delhi in a day. There are 50 seats in the bus and there is no seat vacant both times. The driver of the bus charged Rs. 250 and the conductor charged Rs. 200 for one day. The maintenance charges of the bus is Rs. 750 per day. The bus consumes 50 litres of fuel per day at the rate of Rs 40. Identify the knowing responsibilities of the bus.Options:

a) source of trip , destination of trip, total seats,vacant seats,maintenance charge, fuel consumed

b) cost to the government, trip to , trip from,total seats, vacant seats, occupied seats, fuel consumption, fuel price

c)cost to the government, trip to , trip from,total seats, vacant seats, occupied seats, fuel consumption, fuel price,driver's charge,conductor's charged)total seats, vacant seats, maintenance charge, fuel consumede) total seats, vacant seats, occupied seats,maintenance charge, fuel consumed

30. For a banking system Bank customer is an actor. A customer can use the system to deposit money and withdraw money. The following are the scenarios identified for the system “withdraw cash”, “deposit cash “ , “transfer between accounts” and “validate customer”

Identify the scenarios between which there will be includes relationship.Options:a) “withdraw cash” , “validate customer”b) “deposit cash” , “validate customer”c) “transfer between accounts” , “validate customer”d) “withdraw cash” , “transfer between accounts”e) “deposit cash” , “transfer between accounts”f) a,b &cg) a,bh) a,b,c,d,e

9. From a video store all the valid members can rent a video and can return a video taken for rent. The clerk of the store can also rent a video and return it. A clerk can also maintain video records.

Identify the use case diagram that represents the system for the given scenario.a)

114

Page 115: Class Diagram Example

b)

c)

115

Page 116: Class Diagram Example

d)

e) None of these

116

Page 117: Class Diagram Example

  

117