This document was ed by and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this report form. Report 3i3n4
Consider the class diagram given below. Identify which of the following options best describes the scenario.
Options: a) b) c) d) e)
Class B is tightly coupled Class B has strong cohesion Class B is loosely coupled Class B has weak cohesion 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())); } } class LibraryBook { private String name; public ArrayList <Pages> pages = new ArrayList <Pages>(); LibraryBook(String name, int pgnumber) { this.name = name;
1
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; else return 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
B my_B; A(){ //constructor code; } } class B{ String name; B(){ //constructor code; } } c. class A{ String title; A(){ //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; } }
A(){ //constructor code; } } class B{ String name; A my_A; B(){ //constructor code; } } d. class A{ String title; A(B my_B){ //constructor code; } } class B{ String name; B(){ //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; } } c.
b. class A{ String title; A(){ //constructor code; } } class B{ String name; A my_A; B(){ //constructor code; } } d.
3
class A{ String title; A(){ //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; } }
class A{ String title; A(B my_B){ //constructor code; } } class B{ String name; B(){ //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 association b) bidirectional association c) dependency d) aggregation e) composition f) None of these 5. Refer the code snippet given below class A { private int aField; private String sField; A(String sField, int aField) { this.aField=aField; this.sField=sField; }