February 1st, 2007
[ Team LiB ] 7 Nested Classes and Interfaces 7.1 (e) The code will compile without error and will print 123 when run. An instance of the Outer outer will be created and the field secret will be initialized to 123. A call to the createInner() method will return a reference to a newly created Inner instance. This object is an instance of a non-static member class and is associated with the outer instance. This means that an object of a non-static member class has access to the members within the outer instance. Since the Inner class is nested in the class containing the field secret, this field is accessible to the Inner instance, even though the field secret is declared private. 7.2 (b) and (e) A static member class is in many respects like a top-level class, and can contain non-static fields. Instances of non-static member classes are created in the context of an outer instance. The outer instance is inherently associated with the inner instance. Several inner class instances can be created and associated with the same outer instance. Static classes do not have any inherent outer instance. A static member interface, just like top-level interfaces, cannot contain non-static fields. Nested interfaces are always static. 7.3 (e) The code will fail to compile, since the expression ((State) this).val in the method restore() of the class Memento is invalid. The correct way to access the field val in the class State, which is hidden by the field val in the class Memento, is to use the expression State.this.val. Other than that, there are no problems with the code. 7.4 (d) The program will compile without error, and will print 1, 3, 4, in that order, when run. The expression B.this.val will access the value 1 stored in the field val of the (outer) B instance associated with the (inner) C object denoted by the reference obj. The expression C.this.val will access the value 3 stored in the field val of the C object denoted by the reference obj. The expression super.val will access the field val from A, the superclass of C . Page 621
Hint: This post is supported by Gama web hosting php mysql provider
Posted in hrvatski | No Comments »
February 1st, 2007
[ Team LiB ] Page 620
Hint: This post is supported by Gama web hosting php mysql provider
Posted in hrvatski | No Comments »
February 1st, 2007
Page 619
Hint: This post is supported by Gama web hosting php mysql provider
Posted in hrvatski | No Comments »
February 1st, 2007
Page 618
Hint: If you are looking for very good and affordable webspace to host and run your tomcat hosting application check Sandzak.com tomcat web hosting provider
Posted in hrvatski | No Comments »
February 1st, 2007
Page 617
Hint: If you are looking for very good and affordable webspace to host and run your tomcat hosting application check Sandzak.com tomcat web hosting provider
Posted in hrvatski | No Comments »
February 1st, 2007
Page 616
Hint: If you are looking for very good and affordable webspace to host and run your tomcat hosting application check Sandzak.com tomcat web hosting provider
Posted in hrvatski | No Comments »
February 1st, 2007
[ Team LiB ] 6 Object-oriented Programming 6.1 (a) and (b) The extends clause is used to specify that a class extends another class. A subclass can be declared abstract regardless of whether the superclass was declared abstract. Private, overridden, and hidden members from the superclass are not inherited by the subclass. A class cannot be declared both abstract and final, since an abstract class needs to be extended to be useful and a final class cannot be extended. The accessibility of the class is not limited by the accessibility of its members. A class with all the members declared private can still be declared public. 6.2 (b) and (e) Inheritance defines an is-a relation. Aggregation defines a has-a relation. The Object class has a public method named equals, but it does not have any method named length. Since all classes are subclasses of the Object class, they all inherit the equals() method. Thus, all Java objects have a publicmethod named equals. In Java, a class can only extend a single superclass, but there is no limit on how many classes can extend a superclass. 6.3 (b) and (c) A subclass need not redefine all the methods defined in the superclass. It is possible for a subclass to define a method with the same name and parameters as a method defined by the superclass, but then the return type should also be the same. This is called method overriding. A subclass can define a field that can hide a field defined in a superclass. Two classes cannot be the superclass of each other. 6.4 (a), (b), and (d) Bar is a legal subclass of Foo that overrides the method g(). The statement a.j = 5 is not legal, since the member j in class Bar cannot be accessed through a Foo reference. The statement b.i = 3 is not legal either, since the private member i cannot be accessed from outside of the class Foo. Page 614
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services
Posted in hrvatski | No Comments »
February 1st, 2007
Page 615
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services
Posted in hrvatski | No Comments »
February 1st, 2007
[ Team LiB ] Page 613
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services
Posted in hrvatski | No Comments »
January 31st, 2007
Page 611
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services
Posted in hrvatski | No Comments »