tailieunhanh - Lecture Java™ How to Program (8/e) - Chapter 8: Classes and objects: A deeper look
When you finish this chapter, you should: Encapsulation and data hiding, the notions of data abstraction and abstract data types (ADTs), to use keyword this, to use static variables and methods, to import static members of a class, to use the enum type to create sets of constants with unique identifiers, how to declare enum constants with parameters. | Java™ How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Deeper look at building classes, controlling access to members of a class and creating constructors. Composition—a capability that allows a class to have references to objects of other classes as members. More details on enum types. Discuss static class members and final instance variables in detail. Show how to organize classes in packages to help manage large applications and promote reuse. (C) 2010 Pearson Education, Inc. All rights reserved. Class Time1 represents the time of day. private int instance variables hour, minute and second represent the time in universal-time format (24-hour clock format in which hours are in the range 0–23). public methods setTime, toUniversalString and toString. Clled the public services or the public interface that the class provides to its clients. | Java™ How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Deeper look at building classes, controlling access to members of a class and creating constructors. Composition—a capability that allows a class to have references to objects of other classes as members. More details on enum types. Discuss static class members and final instance variables in detail. Show how to organize classes in packages to help manage large applications and promote reuse. (C) 2010 Pearson Education, Inc. All rights reserved. Class Time1 represents the time of day. private int instance variables hour, minute and second represent the time in universal-time format (24-hour clock format in which hours are in the range 0–23). public methods setTime, toUniversalString and toString. Clled the public services or the public interface that the class provides to its clients. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Class Time1 does not declare a constructor, so the class has a default constructor that is supplied by the compiler. Each instance variable implicitly receives the default value 0 for an int. Instance variables also can be initialized when they are declared in the class body, using the same initialization syntax as with a local variable. (C) 2010 Pearson Education, Inc. All rights reserved. A Time1 object always contains consistent data The object’s data values are always kept in range, even if the values provided as arguments to method setTime were incorrect. In this example, zero is a consistent value for hour, minute and second. hour, minute and second are all set to zero by default; thus, a .
đang nạp các trang xem trước