Question types

Start with

Question limit

of 45 available terms

Print test

45 Multiple choice questions

  1. NSLog (@"The value of myFraction is: ");
    [myFraction print]

    invokes the print method
  2. Describes the data (the instance variables that objects from a class will store) and contains the actual code that implements the methods declared in the interface section.
  3. - (void) setNumerator: (int) n;
  4. Note
  5. car
  6. - (void) setNumerator: (int) n;

    Integer arguments are indicated by the (int) in front of the argument name.
  7. 1. You have to define where the class came from when you define a new class. That is, you have to name it's parent class.

    2. You need to define the type of operations, or methods, that can be used when working with objects from this class.

    3. You also need to list items known as properties
  8. Methods that apply only to your car
  9. Applying a method to an object will affect the state of that object
  10. Your particular car
  11. myFaction = [myFraction init];

    Note that you are not sending the init method to a class, you are sending it to the instance of the class
  12. yourCar = [ Car new ];

    You send a NEW message to the car class (the receiver of the message) asking it to give you a new car. The resulting object (which represents your unique car) is then stored in the variable yourCar. From now on, yourCar can be used to refer to your instance of the car.
  13. Note
  14. You have to describe the data that members of the class will contain. These members are called instance variables. You declare the methods in the @interface section and then you define them in the @implementation section.
  15. A thing.
  16. @implementation NewClassName

    NewClassName is the same name that was used for the class in the @interface section.

    The memberDeclarations section specifies what types of data are stored in your instance of the class. It is enclosed inside its own curly braces

    int numerator;
    int denominator;

    The members declared in this section are known as instance variables. Each time you create a new object, a new and unique set of instance variables are also created.

    The methodDefinition part of the @implementation section contains the code for each method specified in the @interface section.

    Each method starts by identifying the type of the method (class or instance; + or -), its return type, and its arguments and their types. Instead of the line ending in a semicolon, the code for the method follows, enclosed in a set of curly braces.

    -(void) print
  17. Note
  18. An action that is performed on an instance of a class or to the class itself
  19. enough space is reserved in memory to store the object's data, which includes space for its instance variables, and a little more. The location where the data is stored is returned by the alloc routine, and assigned to myFraction.
  20. Note
  21. The method new is an example of a class method because you have to go to the factory to get a new Car.
  22. [ ClassOrInstance method ];
    [ receiver message ];
  23. Note
  24. Make your programs easier to write, code, and maintain.
  25. @interface NewClassName: ParentClassName
  26. - (int) returns an integer
    - (void) returns no value
    - (double) returns a decimal

    Tells the program what type of value the method returns
  27. object oriented programming example
  28. The asterisk represents a reference (or pointer) to a object. The variable myFraction doesn't actually store the fraction's data. Instead it stores a reference - which is a memory address - indicating where the object's data is located in memory. You can think of it as an empty box.
  29. A unique occurrence of a class
  30. Contains the program code to carry out the intended purpose of the program.
  31. Note
  32. They must begin with a letter or underscore (_) and they can be followed by any combination of letters (uppercase or lowercase), underscores, or the digits 0 through 9.
  33. This section contains the code to solve your particular problem, which can be spread out across many files. Somewhere you must have a routine called main. That's where your program begins execution.
  34. myFraction = [Fraction alloc];
  35. myFraction = [[Fraction alloc] init]
  36. note
  37. Fraction *myFraction;
  38. indicates a class method
  39. [ yourCar setSpeed: 55 ];

    set the speed to 55 mph
  40. Fraction *myFraction = [[Fraction alloc] init]
  41. Describes the class and its methods
  42. Note

    return 0;
  43. automatically generates methods for you
  44. // Set fraction to 1/3

    [myFraction setNumerator: 1];
    [myFraction setDenominator: 3];

    The first message statement sends the setNumerator: message to myFraction. The argument that is supplied is the value 1.

    Inside the setNumerator: method, the passed value of 1 is stored inside the variable n. The single program line in that method effectively stores that value in the instance variable numerator.
  45. indicates an instance method