OpenStax-CNX module: m Java3002r Review * R.G. (Dick) Baldwin
|
|
- Beatrice Ellis
- 5 years ago
- Views:
Transcription
1 OpenStax-CNX module: m Java3002r Review * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract This module contains review questions and answers keyed to the module titled Java3002: Creating and Manipulating Turtles and Pictures in a World Object. Revised: Sat Apr 02 14:17:44 CDT 2016 This page is included in the following Books: ITSE Object-Oriented Programming (Java) 1 Object-Oriented Programming (OOP) with Java 2 1 Table of Contents Preface (p. 1) Questions (p. 2) 1 (p. 2), 2 (p. 2), 3 (p. 2), 4 (p. 2), 5 (p. 3), 6 (p. 3), 7 (p. 3), 8 (p. 3), 9 (p. 3), 10 (p. 3), 11 (p. 3), 12 (p. 4), 13 (p. 4), 14 (p. 4), 15 (p. 4), 16 (p. 4), 17 (p. 4), 18 (p. 4), 19 (p. 5), 20 (p. 5), 21 (p. 5), 22 (p. 5), 23 (p. 5), 24 (p. 5), 25 (p. 5), 26 (p. 6), 27 (p. 6), 28 (p. 6), 29 (p. 6), 30 (p. 6), 31 (p. 7), 32 (p. 7), 33 (p. 7), 34 (p. 7), 35 (p. 7), 36 (p. 7), 37 (p. 7), 38 (p. 7), 39 (p. 8), 40 (p. 8), 41 (p. 8), 42 (p. 8), 43 (p. 8), 44 (p. 8), 45 (p. 9), 46 (p. 10), 47 (p. 10), 48 (p. 11), 49 (p. 11), 50 (p. 11) Figures (p. 11) Listings (p. 12) Answers (p. 13) Miscellaneous (p. 19) 2 Preface This module contains review questions and answers keyed to the module titled Java3002: Creating and Manipulating Turtles and Pictures in a World Object 3. The questions and the answers are connected by hyperlinks to make it easy for you to navigate from the question to the answer and back again. * Version 1.6: Apr 2, :18 pm
2 OpenStax-CNX module: m Questions 3.1 Question 1. True or False? The import directive at the very beginning of Listing 1 (p. 2) is a directive to the compiler and the virtual machine notifying them that the class named Color can be found in the package named java.awt. Listing 1. Question 1. import java.awt.color; public class Prob01{//Driver class public static void main(string[] args){ //Instantiate an object and call its method named run. Prob01Runner obj = new Prob01Runner(); obj.run(); //Get information from the object and display it on // the command-line screen. System.out.println(obj.getMars()); System.out.println(obj.getJoe()); System.out.println(obj.getSue()); }//end main }//end class Prob01 Answer 1 (p. 19) Table Question 2 True or False? The class named library. Answer 2 (p. 19) Color imported in Listing 1 (p. 2) is a member of Ericson's multimedia 3.3 Question 3 True or False? A package folder. Answer 3 (p. 18) is the specication of a particular folder on the disk relative to a standard root 3.4 Question 4 True or False? Every Java application and every Java applet must include the denition of a class that contains the denition of a method named main. Answer 4 (p. 18)
3 OpenStax-CNX module: m Question 5 True or False? The name of the class containing the main method is also the name of the application insofar as being able to compile and execute the application is concerned. Answer 5 (p. 18) 3.6 Question 6 True or False? The name of the application shown in Listing 1 (p. 2) is Proj01. Answer 6 (p. 18) 3.7 Question 7 True or False? The name of the source code le containing the class denition shown in Listing 1 (p. 2) must be Prob01.java in order for the application to compile and run as an application named Prob01. Answer 7 (p. 18) 3.8 Question 8 True or False? In its simplest form, an application can be compiled by executing the command shown in Listing 2 (p. 3) at the command prompt where Prob01.java is the name of the le containing the main method. Listing 2. Question 8. javac Prob01 Answer 8 (p. 18) 3.9 Question 9 Table 2 True or False? It is often necessary to specify the path to various library les on the command line when compiling an application. In that case, the simplest form given in Listing 3 (p. 18) is not sucient. Answer 9 (p. 18) 3.10 Question 10 True or False? When a Java application is successfully compiled, it will produce one or more output les with an extension of.class. Answer 10 (p. 18) 3.11 Question 11 True or False? The execution of a Java application begins and ends in the method named main. Answer 11 (p. 18)
4 OpenStax-CNX module: m Question 12 True or False? The two commands shown in Listing 4 (p. 4) can be used to compile and execute a Java application named Prob01 where: The only special class library required is contained in the folder named bookclasses. The path from the root to the folder named bookclasses is represented by \bookclasses. Listing 4. Question 12. javac -cp.;---\bookclasses Prob01.java java -cp.;---\bookclasses Prob01 Answer 12 (p. 17) 3.13 Question 13 Table 3 True or False? The Java compiler program is named java.exe. Answer 13 (p. 17) 3.14 Question 14 True or False? The Prob01.java and Prob01 at the ends of the two commands in Listing 4 (p. 4) specify the les being operated on by the virtual machine and the compiler respectively. Answer 14 (p. 17) 3.15 Question 15 True or False? In Listing 4 (p. 4), the -cp indicates that a classpath follows. Answer 15 (p. 17) 3.16 Question 16 True or False? A classpath consists of one or more path specications separated by semicolon characters. Answer 16 (p. 17) 3.17 Question 17 True or False? The purpose of the classpath in Listing 4 (p. 4) is to tell the compiler and the virtual machine where to look for source code les that the application needs in order to successfully compile and execute. Answer 17 (p. 17) 3.18 Question 18 True or False? The period ahead of the semicolon in Listing 4 (p. 4) says to search the root folder rst. Answer 18 (p. 17)
5 OpenStax-CNX module: m Question 19 True or False? The rst statement in the body of the main method in Listing 1 (p. 2) instantiates a new object of the class named Prob01Runner. Answer 19 (p. 17) 3.20 Question 20 True or False? The rst statement in Listing 1 (p. 2) saves a reference to a new object of the class named Prob01Runner in a reference variable named obj. In general, the type of the variable must be: The name of the object, or The name of a superclass of the object, or The name of an interface implemented by the object. Answer 20 (p. 17) 3.21 Question 21 True or False? In Java, you must save a reference to a newly instantiated object in order to gain access to that object later in the program. Answer 21 (p. 16) 3.22 Question 22 True or False? The second statement in the body of the main method in Listing 1 (p. 2) uses the reference stored in the variable named obj to call the method named run encapsulated in the object referred to by the contents of obj. Answer 22 (p. 16) 3.23 Question 23 True or False? The following three methods that are called in Listing 1 (p. 2) are of a type that is commonly referred to as accessor methods. They are also sometimes referred to by the slang term getter methods. getmars getjoe getsue Answer 23 (p. 16) 3.24 Question 24 True or False? The method named println that is called in Listing 1 (p. 2) is a member of Ericson's multimedia library. The purpose of the println method is to display text on an image. Answer 24 (p. 16) 3.25 Question 25 True or False? Java uses four access modiers to specify the accessibility of various classes and members in a Java application: public private
6 OpenStax-CNX module: m protected package-private Answer 25 (p. 16) 3.26 Question 26 True or False? Listing 5 (p. 6) shows the beginning of a class named Prob01Runner. Listing 5. Question 26. class Prob01Runner{ //Instantiate the World and Turtle objects. private World mars = new World(300,274); private Turtle joe = new Turtle(mars); private Turtle sue = new Turtle(mars); Answer 26 (p. 16) 3.27 Question 27 Table 4 True or False? The class that begins in Listing 5 (p. 6) does not have an access modier. This puts it in package-private access category. A class with package-private access can be accessed by code that is stored in the same package and cannot be accessed by code stored in other packages. Answer 27 (p. 16) 3.28 Question 28 True or False? The last three statements in Listing 5 (p. 6) declare three private variables. Because these variables are declared private, they can be accessed by any method dened in any class in the same package. Answer 28 (p. 16) 3.29 Question 29 True or False? The three variables declared in Listing 5 (p. 6) are instance variables variables. Answer 29 (p. 16) as opposed to class 3.30 Question 30 True or False? Because the three variables declared in Listing 5 (p. 6) are instance variables, they belong to an object instantiated from the class. Even if the variables were public, they could only be accessed by rst gaining access to the object to which they belong. Answer 30 (p. 15)
7 OpenStax-CNX module: m Question 31 True or False? The three variables declared in Listing 5 (p. 6) are reference variables. This means that they are capable of storing references to objects and are also capable of storing values of the eight primitive types. Answer 31 (p. 15) 3.32 Question 32 True or False? Ericson's class library contains a class named World and another class named Turtle. The code in Listing 5 (p. 6) instantiates one object of the World class and populates that world with three objects of the Turtle class. Answer 32 (p. 15) 3.33 Question 33 True or False? Every class denition has one or more method-like members called constructors. (If you don't dene a constructor when you dene a class, a default constructor will be automatically dened for your class.) Answer 33 (p. 15) 3.34 Question 34 True or False? The name of the constructor must always be the same as the name of the class in which it is dened. Like a method, a constructor may or may not take arguments. If there are two or more (overloaded) constructors, they must have dierent argument lists. Answer 34 (p. 15) 3.35 Question 35 True or False? To instantiate an object of a class, you apply the new operator to the class' constructor, passing parameters that satisfy the required arguments for the constructor. Answer 35 (p. 15) 3.36 Question 36 True or False? When an object is instantiated, the constructor returns an array containing the values in all of the instance variables. Answer 36 (p. 15) 3.37 Question 37 True or False? The last two statements in Listing 5 (p. 6) instantiate two objects of the Turtle class and use them to populate the World object whose reference is stored in the variable named mars. Answer 37 (p. 15) 3.38 Question 38 True or False? If a variable (exclusive of local variables inside of methods) is not purposely initialized when the object in instantiated, it will receive a default initialization value. The default values are: 0 or 0.0 for numeric variables true for boolean variables null for reference variables
8 OpenStax-CNX module: m Answer 38 (p. 15) 3.39 Question 39 True or False? Code written into a class' constructor is executed when an object of the class is instantiated. Answer 39 (p. 14) 3.40 Question 40 True or False? Good object-oriented programming practice says that most of the instance variables encapsulated in an object should be declared private. If there is a need to make the contents of those variables available outside the object, that should be accomplished by dening protected accessor methods. Answer 40 (p. 14) 3.41 Question 41 True or False? Everything in Java is passed and returned by reference. Answer 41 (p. 14) 3.42 Question 42 True or False? Each of the accessor methods shown in Listing 6 (p. 8) returns a copy of the reference pointing to either a Turtle object or a World object. Listing 6. Question 42. public Turtle getjoe(){return joe;} public Turtle getsue(){return sue;} public World getmars(){return mars;} Answer 42 (p. 14) 3.43 Question 43 Table 5 True or False? Code in the println method calls a method named tostring on each incoming primitive value and displays the string value returned by that method. Answer 43 (p. 14) 3.44 Question 44 True or False? The tostring method is overridden (not overloaded) so as to return a string value describing the object. Answer 44 (p. 14) in the World and Turtle classes
9 OpenStax-CNX module: m Question 45 True or False? The code in Listing 7 (p. 10) replaces the default all-white picture in a World object with another picture. (Note, the variable named mars contains a reference to an object of the class World.)
10 OpenStax-CNX module: m Listing 7. Question 45. public void run(){ mars.setpicture(new Picture("Prob01.jpg")); Answer 45 (p. 14) 3.46 Question 46 Table 6 True or False? The background of a World object consists of an object of Ericson's Picture class. (A Picture object is encapsulated in the Answer 46 (p. 14) 3.47 Question 47 World object.) True or False? The code in Listing 8 (p. 10) uses two levels of indirection to add my name to the picture that forms the background of the world shown in Figure 1 (p. 10). Listing 8. Question 47. mars.getpicture().tostring( "Dick Baldwin",10,20); Figure 1 (p. 10) - Question 47. Table 7
11 OpenStax-CNX module: m Answer 47 (p. 13) 3.48 Question 48 True or False? A Turtle object encapsulates many methods that can be used to manipulate the turtle in a variety of dierent ways. Answer 48 (p. 13) 3.49 Question 49 True or False? A call to the forward method of a turtle object with no parameters causes the turtle to move forward by a default distance of 100 pixels. Answer 49 (p. 13) 3.50 Question 50 True or False? A call to the moveto method of a turtle object with a single parameter value of 150 causes the turtle to move forward by a distance of 150 pixels. Answer 50 (p. 13) 4 Figures Figure 1 (p. 10). Question 47.
12 OpenStax-CNX module: m Listings Listing 1 (p. 2). Question 1. Listing 2 (p. 3). Question 8. Listing 3 (p. 18). Answer 8. Listing 4 (p. 4). Question 12. Listing 5 (p. 6). Question 26. Listing 6 (p. 8). Question 42. Listing 7 (p. 10). Question 45. Listing 8 (p. 10). Question 47. Listing 9. (p. 14) Answer 47. What is the meaning of the following two images? This image was inserted here simply to insert some space between the questions and the answers to keep them from being visible on the screen at the same time. The image is also an example of the kinds of things that we do in my course titled ITSE 2321, Object- Oriented Programming. This image was also inserted for the purpose of inserting space between the questions and the answers.
13 OpenStax-CNX module: m Answers 6.1 Answer 50 False. The moveto method of the Turtle class cannot be called with a single parameter. Two parameters are required. Back to Question 50 (p. 11) 6.2 Answer 49 Back to Question 49 (p. 11) 6.3 Answer 48 Back to Question 48 (p. 11) 6.4 Answer 47 False. The code in Listing 8 (p. 10) won't compile. The tostring method does not apply to images. The correct code is shown in Listing 9 (p. 14).
14 OpenStax-CNX module: m Listing 9. Answer 47. mars.getpicture().addmessage( "Dick Baldwin",10,20); Back to Question 47 (p. 10) 6.5 Answer 46 Back to Question 46 (p. 10) 6.6 Answer 45 Back to Question 45 (p. 9) 6.7 Answer 44 Back to Question 44 (p. 8) 6.8 Answer 43 Table 8 False. Code in the println method calls a method named tostring on each incoming object reference and displays the string value returned by that method. Back to Question 43 (p. 8) 6.9 Answer 42 Back to Question 42 (p. 8) 6.10 Answer 41 False. Everything in Java is passed and returned by value Back to Question 41 (p. 8), not by reference Answer 40 False. If there is a need to make the contents of those variables available outside the object, that should be accomplished by dening public accessor methods. Back to Question 40 (p. 8) 6.12 Answer 39 Back to Question 39 (p. 8)
15 OpenStax-CNX module: m Answer 38 False. The default values are: 0 or 0.0 for numeric variables false for boolean variables null for reference variables Back to Question 38 (p. 7) 6.14 Answer 37 Back to Question 37 (p. 7) 6.15 Answer 36 False. When an object is instantiated, the constructor returns a reference to the new object. Back to Question 36 (p. 7) 6.16 Answer 35 Back to Question 35 (p. 7) 6.17 Answer 34 Back to Question 34 (p. 7) 6.18 Answer 33 Back to Question 33 (p. 7) 6.19 Answer 32 False. The code in Listing 5 (p. 6) instantiates one object of the with two objects of the Turtle class. Back to Question 32 (p. 7) World class and populates that world 6.20 Answer 31 False. The three variables declared in Listing 5 (p. 6) are reference variables (as opposed to primitive variables). This means that they are capable of storing references to objects as opposed to simply being able to store values of the eight primitive types. It also means that they are incapable of storing values of the eight primitive types. Back to Question 31 (p. 7) 6.21 Answer 30 Back to Question 30 (p. 6)
16 OpenStax-CNX module: m Answer 29 Back to Question 29 (p. 6) 6.23 Answer 28 False. Because these variables are declared private, they can only be accessed by code contained in methods dened inside the same class (and in inner classes of the class, which is beyond the scope of this module). Back to Question 28 (p. 6) 6.24 Answer 27 Back to Question 27 (p. 6) 6.25 Answer 26 Back to Question 26 (p. 6) 6.26 Answer 25 Back to Question 25 (p. 5) 6.27 Answer 24 False. The method named println that is called in Listing 1 (p. 2) is a method belonging to a standard system object that represents the standard output device (usually the command-line screen). The purpose of the println method is to display material on the command-line screen. Back to Question 24 (p. 5) 6.28 Answer 23 Back to Question 23 (p. 5) 6.29 Answer 22 Back to Question 22 (p. 5) 6.30 Answer 21 Back to Question 21 (p. 5)
17 OpenStax-CNX module: m Answer 20 False. In general, the type of the variable must be: The name of the class, or The name of a superclass of the class, or The name of an interface implemented by the class. Back to Question 20 (p. 5) 6.32 Answer 19 Back to Question 19 (p. 5) 6.33 Answer 18 False. The period ahead of the semicolon in Listing 4 (p. 4) says to search the current folder rst. Back to Question 18 (p. 4) 6.34 Answer 17 False. The purpose of the classpath is to tell the compiler and the virtual machine where to look for previously compiled class les that the application needs in order to successfully compile and execute. Back to Question 17 (p. 4) 6.35 Answer 16 Back to Question 16 (p. 4) 6.36 Answer 15 True Back to Question 15 (p. 4) 6.37 Answer 14 False. The Prob01.java and Prob01 at the ends of the two commands in Listing 4 (p. 4) specify the les being operated on by the compiler and the virtual machine respectively. Back to Question 14 (p. 4) 6.38 Answer 13 False. The Java compiler program is named javac.exe. The virtual machine is named java.exe. Back to Question 13 (p. 4) 6.39 Answer 12 Back to Question 12 (p. 4)
18 OpenStax-CNX module: m Answer 11 Back to Question 11 (p. 3) 6.41 Answer 10 Back to Question 10 (p. 3) 6.42 Answer 9 Back to Question 9 (p. 3) 6.43 Answer 8 False. The required command is shown in Listing 3 (p. 18). Listing 3. Answer 8. javac Prob01.java Back to Question 8 (p. 3) 6.44 Answer 7 Back to Question 7 (p. 3) 6.45 Answer 6 Table 9 False. The name of the application shown in Listing 1 (p. 2) is Prob01. Back to Question 6 (p. 3) 6.46 Answer 5 Back to Question 5 (p. 3) 6.47 Answer 4 False. Java applets do not require a method named main. Back to Question 4 (p. 2) 6.48 Answer 3 Back to Question 3 (p. 2)
19 OpenStax-CNX module: m Answer 2 False. java.awt.color belongs to the Java standard edition class library. Back to Question 2 (p. 2) 6.50 Answer 1 Back to Question 1 (p. 2) 7 Miscellaneous This section contains a variety of miscellaneous information. Housekeeping material Module name: Java3002r Review: Creating and Manipulating Turtles and Pictures in a World Object File: Java3002r.htm Published: 02/10/13 Disclaimers: Financial : Although the Connexions site makes it possible for you to download a PDF le for this module at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF le, you should be aware that some of the HTML elements in this module may not translate well into PDF. I also want you to know that, I receive no nancial compensation from the Connexions website even if you purchase the PDF version of the module. In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. I neither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please be aware that it is a copy of a module that is freely available on cnx.org and that it was made and published without my prior knowledge. Aliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX. -end
Java3002: Creating and Manipulating Turtles and Pictures in a World Object
OpenStax-CNX module: m44149 1 Java3002: Creating and Manipulating Turtles and Pictures in a World Object R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons
More informationJava3002: Creating and Manipulating Turtles and Pictures in a World Object *
OpenStax-CNX module: m44149 1 Java3002: Creating and Manipulating Turtles and Pictures in a World Object * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons
More informationJava3018: Darkening, Brightening, and Tinting the Colors in a Picture *
OpenStax-CNX module: m44234 1 Java3018: Darkening, Brightening, and Tinting the Colors in a Picture * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution
More informationJava4340r: Review. R.G. (Dick) Baldwin. 1 Table of Contents. 2 Preface
OpenStax-CNX module: m48187 1 Java4340r: Review R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract This module contains review
More informationJava OOP: Java Documentation
OpenStax-CNX module: m45117 1 Java OOP: Java Documentation R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract Learn to use
More informationJava0078 Java OOP Callbacks - II *
OpenStax-CNX module: m59589 1 Java0078 Java OOP Callbacks - II * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract A previous
More informationHs01006: Language Features, Arithmetic Operators *
OpenStax-CNX module: m37146 1 Hs01006: Language Features, Arithmetic Operators * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0
More informationJava4350: Form Processing with JSP
OpenStax-CNX module: m48085 1 Java4350: Form Processing with JSP R.L. Martinez, PhD This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract This module
More informationINEW Advanced Java Programming. Collection Editor: R.G. (Dick) Baldwin
INEW2338 - Advanced Java Programming Collection Editor: R.G. (Dick) Baldwin INEW2338 - Advanced Java Programming Collection Editor: R.G. (Dick) Baldwin Authors: R.G. (Dick) Baldwin R.L. Martinez, PhD
More informationAuthoring OpenStax Documents in Apache OpenOffice Writer *
OpenStax-CNX module: m60462 1 Authoring OpenStax Documents in Apache OpenOffice Writer * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License
More informationAP Computer Science A, Clarification of the Java Subset. By: R.G. (Dick) Baldwin
AP Computer Science A, Clarification of the Java Subset By: R.G. (Dick) Baldwin AP Computer Science A, Clarification of the Java Subset By: R.G. (Dick) Baldwin Online: < http://cnx.org/content/col11279/1.4/
More informationJava4320: Web Programming Model *
OpenStax-CNX module: m48058 1 Java4320: Web Programming Model * R.L. Martinez, PhD This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract The purpose
More informationAccessible Objected-Oriented Programming Concepts for Blind Students using Java. By: R.G. (Dick) Baldwin
Accessible Objected-Oriented Programming Concepts for Blind Students using Java By: R.G. (Dick) Baldwin Accessible Objected-Oriented Programming Concepts for Blind Students using Java By: R.G. (Dick)
More informationJava4570: Session Tracking using Cookies *
OpenStax-CNX module: m48571 1 Java4570: Session Tracking using Cookies * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract
More informationMultimedia Programming with Java Getting Started
Multimedia Programming with Java Getting Started Learn how to download, install, and test a Java multimedia library developed by Mark Guzdial and Barbara Ericson at Georgia Tech. Also learn how to download,
More informationThe json-simple Java Library. By: R.G. (Dick) Baldwin
The json-simple Java Library By: R.G. (Dick) Baldwin The json-simple Java Library By: R.G. (Dick) Baldwin Online: < http://cnx.org/content/col12010/1.4/ > OpenStax-CNX This selection and arrangement of
More informationJava OOP: Modifications to the Turtle and SimpleTurtle Classes
OpenStax-CNX module: m44348 1 Java OOP: Modifications to the Turtle and SimpleTurtle Classes R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution
More informationPolymorphism - The Big Picture *
OpenStax-CNX module: m34447 1 Polymorphism - The Big Picture * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Learn the essence
More informationHow to make a "hello world" program in Java with Eclipse *
OpenStax-CNX module: m43473 1 How to make a "hello world" program in Java with Eclipse * Hannes Hirzel Based on How to make a "hello world" program in Java. by Rodrigo Rodriguez This work is produced by
More informationMorse1010 Translating Text to Morse Code *
OpenStax-CNX module: m60489 1 Morse1010 Translating Text to Morse Code * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract
More informationAP Computer Science Chapter 10 Implementing and Using Classes Study Guide
AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within
More informationUsing Flex 3 in a Flex 4 World *
OpenStax-CNX module: m34631 1 Using Flex 3 in a Flex 4 World * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract Learn how
More informationChapter 4 Defining Classes I
Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the
More informationGAME : Vector Addition *
OpenStax-CNX module: m45012 1 GAME 2302-0125: Vector Addition * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract Learn
More informationThe Processing Programming Environment. By: Richard Baldwin
The Processing Programming Environment By: Richard Baldwin The Processing Programming Environment By: Richard Baldwin Online: < http://cnx.org/content/col11492/1.5/ > C O N N E X I O N S Rice University,
More informationCmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects
CmSc 150 Fundamentals of Computing I Lesson 28: Introduction to Classes and Objects in Java 1. Classes and Objects True object-oriented programming is based on defining classes that represent objects with
More informationAtelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.
marwan.burelle@lse.epita.fr http://wiki-prog.kh405.net Plan 1 2 Plan 3 4 Plan 1 2 3 4 A Bit of History JAVA was created in 1991 by James Gosling of SUN. The first public implementation (v1.0) in 1995.
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationJava and OOP. Part 2 Classes and objects
Java and OOP Part 2 Classes and objects 1 Objects OOP programs make and use objects An object has data members (fields) An object has methods The program can tell an object to execute some of its methods
More informationCOMP 250 Winter 2011 Reading: Java background January 5, 2011
Almost all of you have taken COMP 202 or equivalent, so I am assuming that you are familiar with the basic techniques and definitions of Java covered in that course. Those of you who have not taken a COMP
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationObject Oriented Programming in C#
Introduction to Object Oriented Programming in C# Class and Object 1 You will be able to: Objectives 1. Write a simple class definition in C#. 2. Control access to the methods and data in a class. 3. Create
More informationTOPIC 8 MORE ON WHILE LOOPS
1 TOPIC 8 MORE ON WHILE LOOPS Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared by B. Ericson.
More informationCS 302 Week 9. Jim Williams
CS 302 Week 9 Jim Williams This Week P2 Milestone 3 Lab: Instantiating Classes Lecture: Wrapper Classes More Objects (Instances) and Classes Next Week: Spring Break Will this work? Double d = new Double(10);
More informationUnit Testing with JUnit in DrJava *
OpenStax-CNX module: m11707 1 Unit Testing with JUnit in DrJava * Stephen Wong Dung Nguyen This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 1.0 Object oriented
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationThe Essence of OOP using Java, Nested Top-Level Classes. Preface
The Essence of OOP using Java, Nested Top-Level Classes Baldwin explains nested top-level classes, and illustrates a very useful polymorphic structure where nested classes extend the enclosing class and
More informationRules and syntax for inheritance. The boring stuff
Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for
More informationJava. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)
Summary: Chapters 1 to 10 Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu
More informationDeclarations and Access Control SCJP tips
Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for
More informationBinghamton University. CS-140 Fall Problem Solving. Creating a class from scratch
Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods
More informationObject Oriented Programming
Object Oriented Programming Objectives To review the concepts and terminology of object-oriented programming To discuss some features of objectoriented design 1-2 Review: Objects In Java and other Object-Oriented
More informationCOMP 202. More on OO. CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading
COMP 202 CONTENTS: static revisited this reference class dependencies method parameters variable scope method overloading More on OO COMP 202 Objects 3 1 Static member variables So far: Member variables
More informationCS 231 Data Structures and Algorithms, Fall 2016
CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationCS1004: Intro to CS in Java, Spring 2005
CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a
More informationJava: Classes. An instance of a class is an object based on the class. Creation of an instance from a class is called instantiation.
Java: Classes Introduction A class defines the abstract characteristics of a thing (object), including its attributes and what it can do. Every Java program is composed of at least one class. From a programming
More informationDay 4. COMP1006/1406 Summer M. Jason Hinek Carleton University
Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information
More informationThis Week. Fields and Variables. W05 Example 1: Variables & Fields. More on Java classes. Constructors. Modifiers
This Week More on Java classes School of Computer Science University of St Andrews Graham Kirby Alan Dearle Constructors Modifiers cdn.videogum.com/img/thumbnails/photos/commenter.jpg http://www.rodgersleask.co.uk/images/sc2.jpg
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationA foundation for programming. Classes and objects. Overview. Java primitive types. Primitive types Creating your own data types
Classes and objects A foundation for programming any program you might want to write objects functions and modules build even bigger programs and reuse code http://www.flickr.com/photos/vermegrigio/5923415248/
More informationJava Magistère BFA
Java 101 - Magistère BFA Lesson 2 Stéphane Airiau Université Paris-Dauphine Lesson 2 (Stéphane Airiau) Java 1 Object Oriented Programming in Java Lesson 2 (Stéphane Airiau) Java 2 Objects and Classes An
More informationIntroduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview
Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple
More informationEncapsulation. Administrative Stuff. September 12, Writing Classes. Quick review of last lecture. Classes. Classes and Objects
Administrative Stuff September 12, 2007 HW3 is due on Friday No new HW will be out this week Next Tuesday we will have Midterm 1: Sep 18 @ 6:30 7:45pm. Location: Curtiss Hall 127 (classroom) On Monday
More informationLecture 2: Java & Javadoc
Lecture 2: Java & Javadoc CS 62 Fall 2018 Alexandra Papoutsaki & William Devanny 1 Instance Variables or member variables or fields Declared in a class, but outside of any method, constructor or block
More informationPrinciples of Object Oriented Programming. Lecture 4
Principles of Object Oriented Programming Lecture 4 Object-Oriented Programming There are several concepts underlying OOP: Abstract Types (Classes) Encapsulation (or Information Hiding) Polymorphism Inheritance
More informationASSIGNMENT 4 Classes and Objects
ASSIGNMENT 4 Classes and Objects COMP-202A, Fall 2010, All Sections Due: Friday, November 19, 2010 (23:55) You MUST do this assignment individually and, unless otherwise specified, you MUST follow all
More informationChapter 4 Java Language Fundamentals
Chapter 4 Java Language Fundamentals Develop code that declares classes, interfaces, and enums, and includes the appropriate use of package and import statements Explain the effect of modifiers Given an
More information3.1 Class Declaration
Chapter 3 Classes and Objects OBJECTIVES To be able to declare classes To understand object references To understand the mechanism of parameter passing To be able to use static member and instance member
More informationJava1486-Fun with Java, Understanding the Fast Fourier Transform (FFT) Algorithm *
OpenStax-CNX module: m49801 1 Java1486-Fun with Java, Understanding the Fast Fourier Transform (FFT) Algorithm * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative
More informationXna0118-The XNA Framework and. the Game Class
OpenStax-CNX module: m49509 1 Xna0118-The XNA Framework and * the Game Class R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract
More informationChapter 4: Writing Classes
Chapter 4: Writing Classes Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Writing Classes We've been using predefined classes. Now we will learn to write our own
More informationObject-Oriented Programming Concepts
Object-Oriented Programming Concepts Real world objects include things like your car, TV etc. These objects share two characteristics: they all have state and they all have behavior. Software objects are
More informationTable of Contents Date(s) Title/Topic Page #s. Chapter 4: Writing Classes 4.1 Objects Revisited
Table of Contents Date(s) Title/Topic Page #s 11/6 Chapter 3 Reflection/Corrections 56 Chapter 4: Writing Classes 4.1 Objects Revisited 57 58-59 look over your Ch 3 Tests and write down comments/ reflections/corrections
More informationIntroduction to Java
Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn
More informationChapter 4. Defining Classes I
Chapter 4 Defining Classes I Introduction Classes are the most important language feature that make object-oriented programming (OOP) possible Programming in Java consists of defining a number of classes
More informationClasses Classes 2 / 35
Classes 1 / 35 Classes Classes 2 / 35 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays
More informationCS 1316 Exam 1 Summer 2009
1 / 8 Your Name: I commit to uphold the ideals of honor and integrity by refusing to betray the trust bestowed upon me as a member of the Georgia Tech community. CS 1316 Exam 1 Summer 2009 Section/Problem
More informationIslamic University of Gaza Faculty of Engineering Computer Engineering Department
Student Mark Islamic University of Gaza Faculty of Engineering Computer Engineering Department Question # 1 / 18 Question # / 1 Total ( 0 ) Student Information ID Name Answer keys Sector A B C D E A B
More informationCLASSES AND OBJECTS. Fundamentals of Computer Science I
CLASSES AND OBJECTS Fundamentals of Computer Science I Outline Primitive types Creating your own data types Classes Objects Instance variables Instance methods Constructors Arrays of objects A Foundation
More information11/19/2014. Objects. Chapter 4: Writing Classes. Classes. Writing Classes. Java Software Solutions for AP* Computer Science A 2nd Edition
Chapter 4: Writing Classes Objects An object has: Presentation slides for state - descriptive characteristics Java Software Solutions for AP* Computer Science A 2nd Edition by John Lewis, William Loftus,
More informationCSCE3193: Programming Paradigms
CSCE3193: Programming Paradigms Nilanjan Banerjee University of Arkansas Fayetteville, AR nilanb@uark.edu http://www.csce.uark.edu/~nilanb/3193/s10/ Programming Paradigms 1 Java Packages Application programmer
More informationASSIGNMENT 5 Objects, Files, and a Music Player
ASSIGNMENT 5 Objects, Files, and a Music Player COMP-202A, Fall 2009, All Sections Due: Thursday, December 3, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified, you
More informationClasses Classes 2 / 36
Classes 1 / 36 Classes Classes 2 / 36 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays
More informationJAVA: A Primer. By: Amrita Rajagopal
JAVA: A Primer By: Amrita Rajagopal 1 Some facts about JAVA JAVA is an Object Oriented Programming language (OOP) Everything in Java is an object application-- a Java program that executes independently
More informationClasses and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?
Peer Instruction 8 Classes and Objects How can multiple methods within a Java class read and write the same variable? A. Allow one method to reference a local variable of the other B. Declare a variable
More informationCLASSES AND OBJECTS. Fundamentals of Computer Science I
CLASSES AND OBJECTS Fundamentals of Computer Science I Outline Primitive types Creating your own data types Classes Objects Instance variables Instance methods Constructors Arrays of objects A Foundation
More informationGAME Motion Displacement and Vectors
OpenStax-CNX module: m45006 1 GAME 2302-0360 Motion Displacement and Vectors R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 Abstract
More informationOperations. I Forgot 9/4/2016 COMPUTER SCIENCE DEPARTMENT PICNIC. If you forgot your IClicker, or your batteries fail during the exam
COMPUTER SCIENCE DEPARTMENT PICNIC Welcome to the 2016-2017 Academic year! Meet your faculty, department staff, and fellow students in a social setting. Food and drink will be provided. When: Saturday,
More informationMIDTERM REVIEW. midterminformation.htm
MIDTERM REVIEW http://pages.cpsc.ucalgary.ca/~tamj/233/exams/ midterminformation.htm 1 REMINDER Midterm Time: 7:00pm - 8:15pm on Friday, Mar 1, 2013 Location: ST 148 Cover everything up to the last lecture
More informationObjects and Classes -- Introduction
Objects and Classes -- Introduction Now that some low-level programming concepts have been established, we can examine objects in more detail Chapter 4 focuses on: the concept of objects the use of classes
More informationSuper-Classes and sub-classes
Super-Classes and sub-classes Subclasses. Overriding Methods Subclass Constructors Inheritance Hierarchies Polymorphism Casting 1 Subclasses: Often you want to write a class that is a special case of an
More informationJava How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.
Java How to Program, 10/e Education, Inc. All Rights Reserved. Each class you create becomes a new type that can be used to declare variables and create objects. You can declare new classes as needed;
More informationASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists
ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists COMP-202B, Winter 2009, All Sections Due: Tuesday, April 14, 2009 (23:55) You MUST do this assignment individually and, unless otherwise
More informationObject-Oriented Programming in Java
Software and Programming I Object-Oriented Programming in Java Roman Kontchakov / Carsten Fuhs Birkbeck, University of London Outline Object-Oriented Programming Public Interface of a Class Instance Variables
More informationComputer Science II (20073) Week 1: Review and Inheritance
Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system
More informationJava Fundamentals (II)
Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class
More informationObjects and Iterators
Objects and Iterators Can We Have Data Structures With Generic Types? What s in a Bag? All our implementations of collections so far allowed for one data type for the entire collection To accommodate a
More informationHandout 7. Defining Classes part 1. Instance variables and instance methods.
Handout 7 CS180 Programming Fundamentals Spring 15 Page 1 of 8 Handout 7 Defining Classes part 1. Instance variables and instance methods. In Object Oriented programming, applications are comprised from
More informationDistributed Systems Recitation 1. Tamim Jabban
15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming
More information엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University COPYRIGHTS 2017 EOM, HYEONSANG ALL RIGHTS RESERVED
엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University COPYRIGHTS 2017 EOM, HYEONSANG ALL RIGHTS RESERVED Outline - Questionnaire Results - Java Overview - Java Examples
More information390 Object-Based Programming Chapter 8. Copyright 2002 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
temp.fm Page 390 Tuesday, September 25, 2001 3:46 PM 390 Object-Based Programming Chapter 8 Software Engineering Observation 8.11 The class designer need not provide set and/or get methods for each private
More informationTOPIC 12 CREATING CLASSES PART 1
1 TOPIC 12 CREATING CLASSES PART 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared by B. Ericson.
More informationOOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.
OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.
More informationCOMP-202 Unit 8: Defining Your Own Classes. CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation
COMP-202 Unit 8: Defining Your Own Classes CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation Defining Our Own Classes (1) So far, we have been creating
More informationChapter 6 Lab Classes and Objects
Gaddis_516907_Java 4/10/07 2:10 PM Page 51 Chapter 6 Lab Classes and Objects Objectives Be able to declare a new class Be able to write a constructor Be able to write instance methods that return a value
More informationWhat will this print?
class UselessObject{ What will this print? int evennumber; int oddnumber; public int getsum(){ int evennumber = 5; return evennumber + oddnumber; public static void main(string[] args){ UselessObject a
More informationPrelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion
Prelim 1 CS 2110, October 1, 2015, 5:30 PM 0 1 2 3 4 5 Total Question Name True Short Testing Strings Recursion False Answer Max 1 20 36 16 15 12 100 Score Grader The exam is closed book and closed notes.
More information