Fichas
Objects, Methods
Fichas del conjunto (39)
- 1describe "type' using entitiesentities grouped together by some sort of similarity
• can be thought of as a (mathematical) set of entities - 2what is equivalent of entity in programming?object
- 3what is equivalent of type in programming?class
- 4what is equivalent of subtyping in programming?inheritance
- 5which of following need to be present in the language for it to be called object oriented? 1. object, 2. class, 3.inheritance1 and 2 are necessary, 3 is optional.
- 6which of following need to be present in the language for it to be called object oriented? 1. subtyping, 2. entities, 3.type2 (objects) and 3 (classes) are necessary, 1(inheritance) is optional
- 7what is an invariant?a condition that always holds for an entity
- 8what is a condition that always holds for an entity called?invariant
- 9give example of invarianta condition that always holds for an entity
⋄ e.g. neither the age, nor the height of a person can be negative - 10what is a property called in OO languages?data field
- 11what is an operation called in OO languages?method
- 12is instation of an object pure or has side effect?the instantiation expression has a side effect (the object is created)
- 13what is return value of object instatiation?reference to the object
- 14what is a keyword for immutable primitive types?final
- 15can immutable reference types be modified to refer to another object?no
- 16can immutable reference types be modified to refer to null object?no
- 17how is immutability implemented?the pointer (with the memory address) is immutable
- 18can the date of an immutable object change?yes
- 19what is the field which always has exactly one instance of it, and that belongs to the classstatic
- 20do instances own an independent copy of a static field?no
- 21can a static field exist if no instances of the class have been made?yes
- 22where is a static field stored, heap or memory?heap
- 23is the class loaded before the first use of it(instance), or is it loaded when creating first instance?it's loaded before
- 24does java create a default constructor if other one has been coded?no
- 25how can a constructor call other constructors?with "this" keyword
- 26where can a call to another constructor appear?it can only be the first statement in the constructor
- 27which of these can we overload: number or types of arguments?both
- 28how can arguments be passed upon method/constructor invocation?call by value, call by sharing
- 29when (call by value or sharing) is an argument reference?call by sharing
- 30which types are passed by value in java?primitive types
- 31how are primitive types passed in java, by value or by sharing?value
- 32how can we ensure preserving invariants for the objectby encapsulation
- 33(encapsulation) what is deifference between shallow and deep copy?• shallow copy: only the outmost references are separated (used on arrays, the clone method makes such a copy)
• deep copy: when shallow copying is not enough, all internal references
are copied - 34which can be initialised with null value, variables or objects?both
- 35which type of access modifiers make up the interface of an object?public
- 36how can we use method chaining?by returning that object at the end of method
- 37which one returns void as return type, function or procedure?procedures
- 38how can can static methods have "this": as its argument or return type?neither
- 39can static methods call non-static methods?no, except if we pass it an object reference
Información
- Descripción
- Fichas sobre Objects, Methods, creado por Ia Mgvdliashvili el 15/12/2017.
- Creado por
- Ia Mgvdliashvili
- Visitas
- 0
- Valoración