Due December 8th, at noon 1/3 Tutorial 8 F21 – COMP1006/1406 – Introduction to Computer Science II Objectives Use a Java package. Complete either Tutorial 6 or 7. Notes Exercise 1 is asking you...

1 answer below »
Complete this tutorial which is a homework question code the following problems


Due December 8th, at noon 1/3 Tutorial 8 F21 – COMP1006/1406 – Introduction to Computer Science II Objectives Use a Java package. Complete either Tutorial 6 or 7. Notes Exercise 1 is asking you compile files that are in a Java package and then run a program in that package. Exercise 2 is asking you to complete either Tutorial 6 or 7 (whichever you did not do last time). QUESTION 1 Taken from the Oracle tutorial pages (https://docs.oracle.com/javase/tutorial/java/package/packages.html) To make types easier to find and use, to avoid naming conflicts, and to control access, programmers bundle groups of related types into packages. A package is a grouping of related types (which include classes, interfaces, enumerations and annotation types) providing access protection and namespace management. The types that are part of the Java platform are members of various packages that bundle classes by their function. For example, fundamental classes are in java.lang, classes for reading and writing (input and output) are in java.io, and so on. You can make your own packages too. Why collect the classes and interfaces into a package? • You and other programmers can easily determine that these types are related. • The names of your types won't conflict with the type names in other packages because the package creates a new namespace. • You can allow types within the package to have unrestricted access to one another yet still restrict access for types outside the package. https://docs.oracle.com/javase/tutorial/java/package/packages.html Due December 8th, at noon 2/3 The default access modifier (i.e., the absence of an access modifier) specifies that any other type within the package can access it. It is sometimes referred to as package-private access. When using a package, call it ourPackage, all files must be in a directory (folder) with the same name (ourPackage). Each file must also have the package directive at the top of the file: package packageName; Now, an issue that many face when using packages is that compiling and running is done slightly different. In this exercise, you will be using a command prompt (windows cmd or mac Terminal) to manually compile and run code from a package. Download the tutotial08.zip file and unzip its contents. You will find a directory called tutotial08 and several files inside it. Notice that each file has package tutorial08; as its first line. Compiling: Go to the directory that has the tutotial08 folder in it. Do not go into the tutotial08 directory though. Compile all the java files in the tutorial08 directory with the following command based on your OS. Using windows: javac tutorial08\*.java Using a Mac or Linux: javac tutorial08/*.java This will compile all the files in the folder. You could have moved into the directory and directly compiled the files from there (like you would have done in previous tutorials), but to be consistent with running a program, it is best to compile from the same directory that contains the directory with the package contents. Running: To run the Tut08 program, from the directory that has the tutorial08 directory, invoke the JVM with the following command java tutorial08.Tut08 Notice that the [back]slash is replaced with a dot. This will run the tut08 program. Try to compile and run the UsePackage.java program. This program is NOT part of the tutorial08 package, but it uses one of its classes. Due December 8th, at noon 3/3 QUESTION 2 You had the option of either completing Tutorial 7 or the optional Tutorial 6. Complete whichever one you did NOT do and submit the files here in the Tutorial 8 submission link.
Answered 1 days AfterDec 04, 2021

Answer To: Due December 8th, at noon 1/3 Tutorial 8 F21 – COMP1006/1406 – Introduction to Computer Science II...

Kondalarao answered on Dec 06 2021
118 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here