Presentation is loading. Please wait.

Presentation is loading. Please wait.

UML Package Diagrams. package_name presentation view controller model.

Similar presentations


Presentation on theme: "UML Package Diagrams. package_name presentation view controller model."— Presentation transcript:

1 UML Package Diagrams

2 package_name

3 presentation view controller model

4 uk::ac::aber::dcs::roladex tests Roladex Contact Roladex Application * We can also show associations and other relationships that span packages

5 Qwizdom review on packages, JARs and access modifiers

6 Java named packages provide the following benefits (choose all that apply) A.We don’t need to use the import statement nor a class’s fully qualified name B.They make our code more maintainable C.They enable the creation of libraries of classes that others can use D.They make out code run faster E.They help to uniquely name classes

7 Why use package names that mimic Internet domain names (e.g. uk.ac.aber.dcs)? (Choose the most relevant option) A.Because it ensures that my fully qualified class- name will be unique and not clash with any other class B.Because it shows that the class was implemented by that organisation (e.g. Aber Uni) C.Because it shows that my class is accessible on the Internet via a communications channel D.I don’t know

8 True or False In order to refer in your class to another user- define class declared in another package then you must import that class using an import statement.

9 True or False When using a class defined in the Java class library then it is always necessary to either import it explicitly or to use its fully qualified name.

10 Assume that you have the following folder structure, and that you wish to compile the JUnit test class ContactTest.java from the command line within the folder C:\Users\cwl\uk\ac\aber\dcs\roladex\tests. ContactTest is in the package uk.ac.aber.dcs.roladex.tests and uses the class Contact which is in the package uk.ac.aber.dcs.roladex. Which one of the following calls to javac is correct? A.javac ContactTest.java B.javac –cp C:\Users\cwl ContactTest.java C.javac –cp C:\Users\cwl;C:\junit\junit.jar ContactTest.java D.javac –cp C:\Users\cwl\uk;C:\junit\junit.jar ContactTest.java

11 Why is it generally not a good idea to set the CLASSPATH global environment variable? (Choose all relevant options) A.It slows down the JVM or Java compiler performance B.It can cause Java to download classes over the Internet C.It can expose inappropriate classes to the JVM or Java compiler D.It can result in compilation or runtime errors

12 What advantages to JAR files provide? (Choose all that apply) A.Convenient way to package and distribute code B.The allow us to hermetically seal in the file contents C.They allow us to run java code without having to identify the main class on the command line: java –jar application.jar D.They are compressed like zip files and therefore their contents can be sent more efficiently across the network E.You can digitally sign them so that users of the JARs can decide whether to trust them or not

13 Which of the following top-level class declarations are correct? (Choose all that apply) A.private class MyClass{ } B.protected class MyClass{ } C.class MyClass{ } D.public class MyClass{ }

14 package my_project; public class MyClass { MyClass(){ } } Given the above, which one of the following is legal? A. B. package my_project; public class Test { public void test(){ MyClass mc = new MyClass(); } package other_project; import my_project.MyClass; public class Test { public void test(){ MyClass mc = new MyClass(); }

15 package my_project; public class MyClass { protected MyClass(){ } } Given the above, which of the following are legal (choose all that apply)? A. B. C. package my_project; public class Test { public void test(){ MyClass mc = new MyClass(); } package other_project; import my_project.MyClass; public class MyOtherClass extends MyClass { public MyOtherClass(){ super(); } package other_project; import my_project.MyClass; public class Test { public void test(){ MyClass mc = new MyClass(); }

16 Why are protected instance variables less safe that package-private instance variables (choose one)? A.This statement is false, they are just as safe as package-private instance variables B.Because they can be accessed from subclasses possibly in different packages

17 True or False The following code will not compile because age is declared as private public class Person { private int age = 0; public void setAsSameAge(Person otherPerson){ this.age = otherPerson.age; }


Download ppt "UML Package Diagrams. package_name presentation view controller model."

Similar presentations


Ads by Google