Archive for January, 2007

[ Team LiB ] 2 Language Fundamentals 2.1

Tuesday, January 30th, 2007

[ Team LiB ] 2 Language Fundamentals 2.1 (c) 52pickup is not a legal identifier. The first character of an identifier cannot be a digit. 2.2 (e) In Java, the identifiers delete, thrown, exit, unsigned, and next are not keywords. Java has a goto keyword, but it is reserved and not currently used. 2.3 (b) It is a completely valid comment. Comments do not nest. Everything from the start marker of a comment block (/*) until the first occurrence of the end marker of the comment block (*/) is ignored by the compiler. 2.4 (a) and (d) String is a class, and “hello” and “t” denote String objects. Java only has the following primitive data types: boolean, byte, short, char, int, long, float, and double. 2.5 (a), (c), and (e) Type (a) is a boolean data type, while types (c) and (e) are floating-point data types. 2.6 (c) The bit representation of int is 32-bits wide and can hold values in the range 231 through 231 1. Page 592
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra j2ee hosting services

[ Team LiB ] Appendix D. Annotated Answers

Tuesday, January 30th, 2007

[ Team LiB ] 1 Basics of Java Programming 1.1 (d) A method is an operation defining the behavior for a particular abstraction. Java implements abstractions, using classes that have properties and behavior. Behavior is dictated by the operations of the abstraction. 1.2 (b) An object is an instance of a class. Objects are created from class definitions that implement abstractions. The objects that are created are concrete realizations of those abstractions. 1.3 (b) The code marked with (2) is a constructor. A constructor in Java is declared like a method, except that the name is identical to the class name and it does not specify a return value. 1.4 (b) and (f) Two objects and three reference variables are created by the code. Objects are typically created by using the new operator. Declaration of a reference variable creates a variable regardless of whether a reference value is assigned to it or not. 1.5 (d) An instance member is a field or an instance method. These members belong to an instance of the class rather than the class as a whole. Members which are not explicitly declared static in a class definition are instance members. 1.6 (c) An object can pass a message to another object by calling an instance method of the other object. Page 590
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

[ Team LiB ] Appendix D. Annotated Answers

Tuesday, January 30th, 2007

[ Team LiB ] Page 591
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

[ Team LiB ] Appendix D. Annotated Answers

Tuesday, January 30th, 2007

[ Team LiB ] Appendix D. Annotated Answers to Review Questions Section 1. Basics of Java Programming Section 2. Language Fundamentals Section 3. Operators and Assignments Section 4. Declarations and Access Control Section 5. Control Flow, Exception Handling, and Assertions Section 6. Object-oriented Programming Section 7. Nested Classes and Interfaces Section 8. Object Lifetime Section 9. Threads Section 10. Fundamental Classes Section 11. Collections and Maps [ Team LiB ] Page 589
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

[ Team LiB ] Section 6: Overloading, Overriding,

Monday, January 29th, 2007

[ Team LiB ] Section 7: Threads . Recognize conditions that might prevent a thread from executing. Write code using synchronized wait, notify and notifyAll to protect against concurrent access problems and to communicate between threads. . Define the interaction among threads and object locks when executing synchronized wait, notify, or notifyAll. Relevant Sections Read Sections 9.4 “Synchronization” and Section 9.5 “Thread Transitions.” Study Notes Various method calls and events may cause a thread to go from one state to another. Several conditions may prevent a thread from executing. A good understanding of object locks and synchronized code is required. Note the difference between the notify() and notifyAll() methods. [ Team LiB ] Page 587
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check professional tomcat hosting services

[ Team LiB ] Section 6: Overloading, Overriding,

Monday, January 29th, 2007

[ Team LiB ] Section 8: The Collections Framework . Make appropriate selection of collection classes/interfaces to suit specified behavior requirements. . Distinguish between correct and incorrect implementations of hashcode methods. Relevant Sections Read Chapter 11. Study Notes The collections framework consists of various interfaces, concrete implementations of collections, and utility classes. Familiarity with the methods defined by the interfaces is required. Some collection interfaces are better suited for certain types of information. Knowledge of which collection implementation is best suited for a particular situation is important. The hashCode() method of two objects must return the same result if the state of the objects are equal according to the equals() method, and must consistently return the same result as long as the state remains the same. Correct implementation of the hashCode() and its relation to the equals() method must be understood. [ Team LiB ] Page 588
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check professional tomcat hosting services

[ Team LiB ] Section 6: Overloading, Overriding,

Monday, January 29th, 2007

[ Team LiB ] Section 6: Overloading, Overriding, Runtime Type and Object Orientation . Write code to invoke overridden or overloaded methods and parental or overloaded constructors; and describe the effect of invoking these methods. . Write code to construct instances of any concrete class including normal top-level classes and nested classes. Relevant Sections Read Sections 6.1 “Single Implementation Inheritance” through Section 6.3 “Chaining Constructors Using this() and super().” See also Sections 4.4 “Constructors,” 7.3 ” Non-static Member Classes,”and 7.4 “Local Classes” for constructing instances of nested classes. Study Notes Pay attention to which casts are allowed between superclasses and subclasses at compile time, and the effect of casts at runtime. Polymorphism is the result of dynamic method binding of overridden methods at runtime, and the binding is based on the actual type of the object, not the type of the reference. It is illegal for overriding methods to contradict the declaration of the overridden methods. Overloaded methods are distinct methods not subject to dynamic method binding. The ability to overload method names is purely a result of methods being identified by the full signature, rather than just by the method name. Special language constructs allow explicit access to variables and methods in superclasses and in enclosing contexts. Shadowed variables can be accessed, and overriding methods may call the overridden versions of the methods. Interface and class definitions can be nested. The exact nature of such definitions and the restrictions placed on the definitions depend on the declaration context. Instances of some nested classes are associated with an outer instance. It is important to understand the correlation between an instance of an inner class and the outer class, and what can be accessed from within an inner class and how. There are several ways of declaring nested classes, and this affects the correlation between an instance of an inner class and its outer class. [ Team LiB ] Page 586
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check professional tomcat hosting services

[ Team LiB ] Section 3: Garbage Collection

Monday, January 29th, 2007

[ Team LiB ] Section 5: Operators and Assignments . Determine the result of applying any operator (including assignment operators and instance of) to operands of any type class scope or accessibility or any combination of these. . In an expression involving the operators &, |, &&, || and variables of known values state which operands are evaluated and the value of the expression. . Determine the effect upon objects and primitive values of passing variables into methods and performing assignments or other modifying operations in that method. Relevant Sections Read Chapter 3. The subsection “Object Value Equality” in Section 3.10 is not covered by the objectives. See also subsection “Reference Casting and instanceof Operator” in Section 6.6. Study Notes Operators require operands of certain types. The operands used with an operator influence which conversions can occur, and determine the type of the resulting expression. Some operators, such as +, can be applied to non-numeric values. Some operators are related, such as >> and >>>, | and ||, & and &&, but their behaviors are different. There are several forms of conversions, and all except for casts occur implicitly depending on the context. The key to casting and conversion is to know the rules for widening numeric promotion, narrowing conversion, and conversion of references up and down the inheritance hierarchy (upcasting and downcasting). The instanceof operator returns true if an object can be cast to the given reference type. Some operators exhibit short-circuit behavior, which means that some operands may never be evaluated. Parameters are passed by value. Methods get their own copy of the argument values. This holds for values of primitive data types, as well as for reference values denoting objects. Objects themselves are not passed as arguments. [ Team LiB ] Page 585

Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Sandzak.com java web hosting provider

[ Team LiB ] Section 3: Garbage Collection

Monday, January 29th, 2007

[ Team LiB ] Section 4: Language Fundamentals . Identify classes that correctly implement an interface where that interface is either java.lang.Runnable or a fully specified interface in the question. . State the effect of using a variable or array element of any kind when no explicit assignment has been made to it. Relevant Sections Read Sections 2.3 “Variable Declarations” and 2.4 “Initial Values for Variables.” For interface implementation, see Section 6.4 “Interfaces.” For implementation of java.lang.Runnable, see Section 9.3 “Thread Creation.” Study Notes Interfaces can be defined within several contexts, and the contexts influence the meaning of the declaration and the modifiers applicable. The modifiers used also influence the restrictions that apply for the implementation of methods. Certain rules of consistency must be observed when extending or implementing interfaces. Methods are distinguished from each other at compile time, based on the method signature. Each primitive data type has a range of valid values and a default value. Depending on the context of the declaration, some variables are either initialized to a default value or remain uninitialized until first assigned a value. Code that tries to access uninitialized variables is illegal. Elements of array objects are always initialized. [ Team LiB ] Page 584

Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Sandzak.com java web hosting provider

[ Team LiB ] Section 3: Garbage Collection

Monday, January 29th, 2007

[ Team LiB ] Section 3: Garbage Collection . Recognize the point in a piece of source code at which an object becomes eligible for garbage collection. Relevant Sections Read subsections “Reachable References” and “Facilitating Garbage Collection” in Section 8.1. Study Notes An object becomes eligible for garbage collection when it has no references from running code. If a reference is reassigned, the object previously denoted by the reference now has one less reference, increasing this object’s chances of becoming eligible for garbage collection. It is important to be able to identify where in the code an object will have no references during execution. [ Team LiB ] Page 583

Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Sandzak.com java web hosting provider