![]() In the preceding chapters, we detailed separately the components of the three dimensions: scientific and engineering practices, crosscutting concepts, and disciplinary core ideas. Students actively engage in scientific and engineering practices in order to deepen their understanding of crosscutting concepts and disciplinary core ideas. Write a program to testclass Rectangle.ġ // Exercise 8.4 Solution: Rectangle.This framework is designed to help realize a vision of science education in which students’ experiences over multiple years foster progressively deeper understanding of science. The set methods should verify that length andwidth are each floating-point numbers larger than 0.0 and less than 20.0. Ithas set and get methods for both length and width. It has methods that calculate the perimeter and the area of the rectangle. The class has attributes length and width, eachof which defaults to 1. Package access does not promote good OOP when applied to an instancevariable because it destroys the notion of information hiding.Ĩ.3 What happens when a return type, even void, is specified for a constructor?ANS: It is treated as a method and is not considered to be a constructor.Ĩ.4 (Rectangle Class) Create a class Rectangle. Explain the negative aspects of package access.ĪNS: Package access allows a class, method, or variable to be accessible within the samepackage. ANS: public services, public interface.y) System class static method indicates that the garbage collector should makeĪ best-effort attempt to reclaim objects that are eligible for garbage collection.ANS: gc.z) An object that contains has data values that are always kept in range.ANS: consistent data.Įxercises 8.2 Explain the notion of package access in Java. The javac or java command, or by setting the environment variable.ANS: -classpath, CLASSPATH.v) Set methods are sometimes called because they typically change a value.ANS: mutator methods.w) A(n) imports all static members of a class.ANS: static import on demand.x) The public methods of a class are also known as the class’s or. S) A(n) declaration imports only the classes that the program uses from a partic-ular package.ĪNS: type-import-on-demand.t) The compiler uses a(n) to locate the classes it needs in the classpath.ANS: class loader.u) The classpath for the compiler and JVM can be specified with the option to r) There can be only one in a Java source-code file, and it must precede all otherĭeclarations and statements in the file.ANS: package declaration. That the code needs to accomplish its designated task.ANS: principle of least privilege.p) Keyword specifies that a variable is not modifiable.ANS: final.q) A(n) consists of a data representation and the operations that can be per-įormed on the data.ANS: abstract data type (ADT). Of the class.ANS: static.n) A(n) declaration imports one static member.ANS: single static import.o) The states that code should be granted only the amount of privilege and access ![]() ANS: accessor methods, query methods.i) A(n) method tests whether a condition is true or false.ANS: predicate.j) For every enum, the compiler generates a static method called that returns anĪrray of the enum’s constants in the order in which they were declared.ANS: values.k) Composition is sometimes referred to as a relationship.ANS: has-a.l) A(n) declaration contains a comma-separated list of constants.ANS: enum.m) A(n) variable represents classwide information that is shared by all the objects ANS: default constructorg) An object’s method is called implicitly when an object appears in code whereĪ String is needed.ANS: toString.h) Get methods are commonly called or. Memory.ANS: finalize.e) A(n) declaration specifies one class to import.ANS: single-type-import.f) If a class declares constructors, the compiler will not create a(n). ![]() Local variable the field in that method’s scope.ANS: shadows.d) The method is called by the garbage collector just before it reclaims an object’s Turns a formatted String rather than displaying a String in a command window.ANS: format.c) If a method contains a local variable with the same name as one of its class’s fields, the ![]() Self-Review Exercises8.1 Fill in the blanks in each of the following statements:Ī) When compiling a class in a package, the javac command-line option speci-fies where to store the package and causes the compiler to create the package’s directo-ries if they do not exist.ĪNS: -d.b) String class static method is similar to method, but re. 2 Chapter 8 Classes and Objects: A Deeper Look
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |