UML Package Diagrams. package_name presentation view controller model.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
Advertisements

OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Processing and Java David Meredith
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Packages Sudhir Talasila Preeti Navale. Introduction Packages are nothing more than the way we organize files into different directories according to.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
EEC-681/781 Distributed Computing Systems Java Tutorial Wenbing Zhao Cleveland State University
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
Information Hiding and Encapsulation
1 Chapter 3 Programs and Packages. 2 Java Virtual Machine (JVM) Java programs execute on the JVM. The JVM is a virtual rather than a physical machine,
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Vocabulary Key Terms polymorphism - Selecting a method among many methods that have the same name. subclass - A class that inherits variables and methods.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
1 CSE 331 Java Packages; JAR Archives slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
UML Basics & Access Modifier
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA ‏ Packages.
Cs3180 (Prasad)L8Packages1 Packages Organizing large programs => From monolithic programs to partitioning class name space Access control of names => Enforcing.
Dale Roberts Object Oriented Programming using Java - Packages Dale Roberts, Lecturer Computer Science, IUPUI Department.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and.
Packages. Package 1.Avoid naming conflicts. Put classes into packages so that they can be referenced through package names. 2.Distribute software conveniently.
Slide 1 Unit Testing. Slide 2 Unit Testing Options l Use N-Unit In a microsoft environment.NET… you can use their supplied N-Unit testing to test your.
4/1/05F-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Packages and Components in Java and UML.
EE2E1. JAVA Programming Lecture 3 Java Programs and Packages.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
CS 61B Data Structures and Programming Methodology July 3, 2008 David Sun.
CSC 142 D 1 CSC 142 Instance methods [Reading: chapter 4]
Programming in Java CSCI-2220 Object Oriented Programming.
 All calls to method toString and earnings are resolved at execution time, based on the type of the object to which currentEmployee refers.  Known as.
SilkTest 2008 R2 SP1: Silk4J Introduction. ConfidentialCopyright © 2008 Borland Software Corporation. 2 What is Silk4J? Silk4J enables you to create functional.
Pre- and postconditions, Using assertions and exceptions 1 Pre- and postconditions Using assertions and exceptions.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Inheritance Revisited Other Issues. Multiple Inheritance Also called combination--not permitted in Java, but is used in C++ Also called combination--not.
M1G Introduction to Programming 2 5. Completing the program.
Chapter 8 Inheritance. 2  Review of class relationships  Uses – One class uses the services of another class, either by making objects of that class.
Classes Dwight Deugo Nesa Matic
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 5 Methods.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Packages. Access Specifications Public Available anywhere (public keyword) Only one public class per file allowed Protected Available in subclasses, and.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Classes, Interfaces and Packages
Java Package Advantage of Java Package
Generics. Writing typed checked generic code There are many instances where the type of the object is irrelevant : –The construction of data structures.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
 2005 Pearson Education, Inc. All rights reserved. 1 Classes and Objects: A Deeper Look.
Inheritance and Polymorphism
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
BY:- TOPS Technologies
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
Java Programming (By Rama Bhadra Rao M) You can Trace me in Day 2
JAVA MULTIPLE CHOICE QUESTION.
Interface, Subclass, and Abstract Class Review
Inheritance and Polymorphism
Packages When we name a program , we name it by class name…
Internet and Java Foundations, Programming and Practice
Java Basics Packages.
Conditional Statements
Packages and Interfaces
More Model Elements.
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
Applying OO Concepts Using Java
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Presentation transcript:

UML Package Diagrams

package_name

presentation view controller model

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

Qwizdom review on packages, JARs and access modifiers

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

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

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.

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.

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

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

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

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{ }

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(); }

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(); }

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

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; }