powerpoint 7.txt

The flashcards below were created by user dimeng on FreezingBlue Flashcards.

  1. The attributes of an object (that describe its state) are called ____________.
    instance variables
  2. In addition to attributes, classes can have _____________.
  3. What is the standard way of describing a class?
    A UML diagram.
  4. In the cookie cutter/cookie analogy, the class is the _________________ while the object is the ____________.
    cookie cutter (structure), cookie (instance)
  5. How many classes should be in a .java file?
  6. Can classes compile without a program?
  7. What is the minimum number of classes that should be in a program?
    1 - the file that holds the main method is also in a class
  8. An object is an ______________ of a class.
  9. How should you decide if a variable or a method that is part of a class should be public or private?
    Variables should be private. Methods should be private unless there is a compelling reason to make them public.
  10. What is the syntax for declaring a new instance of a class (an object)?
    className objectName = new className();
  11. When a new object is created, what happens in Java?
    The memory is allocated and the memory address of the object is assigned to the variable.
  12. What does the modifier "public" mean?
    It means that any other class can directly use or access the class, method, or instance variable by name.
  13. What does the modifier "private" mean?
    It means that no other class can directly use or access the class, method, or instance variable by name, but they can be accessed within the parent class.
  14. What can you do to make variables retreivable if they are private and you need to know access them outside of the parent class?
    You can make helper methods that return the value of private variables.
  15. Do NOT declare ___________ classes private. They will be unusable, as no one will be able to access them.
  16. What is a constructor?
    A constructor is a special type of method that is invoked when you create an object of a class with new.
  17. What does a constructor do?
    A constructor creates and initializes a new object whose address is then given back to the object.
  18. Constructors have ________ return type/value.
  19. Constructors really return the ____________ of the newly created object.
  20. Constructors must have the same ________ as the name of the class.
  21. When a constructor is called, Java __________________ to all instance variables.
    assigns default values
  22. If you don't create a constructor, ____________________________.
    Java creates one for you
  23. If you create even one custom constructor, Java __________________________.
    won't do it for you anymore, and you must create a "default" type constructor
  24. Always make your own _______________ constructor (even if you don't plan to use it).
  25. What is this? What does it do?
    "this" is a reserved word in Java. Inside the definition of a method, it points to the object receiving the method call. It is usually optional, but good practice to use it.
  26. Constructors can/can not call other constructors.
    Can. It must be the first action taken by the constructor, though.
Card Set:
powerpoint 7.txt
2015-04-05 00:32:07
diane cs140
diane cs140 powerpoint 7
Show Answers: