CMSC 131 Final Exam Spring (All Correctly Answered)
What two things make up an object? correct answers State and Behavior What is the State of an object? correct answers Data that the object maintains/holds Ex: (Bank Account) - balance, account number, interest amount, account type etc Behavior of an object? correct answers Things the object can do Ex: (Bank Account) - giveMeMoney, acceptDeposits, getBalance etc What represents a state of an object? correct answers Instance Variables Ex: (Student Class) Public int IdNum; Public String name; What represents a behavior of an object? correct answers Instance Methods Ex: (Student Class) Public void spendToken() { tokenLevel--; } Define the Stack? correct answers Simple linear date type in which elements are both inserted (pushed) and removed (popped) from the same end. They are pushed or popped from the top. Define the Heap correct answers Region in memory where objects, class variables, and instance variables are stored. When they are no longer used, they are "recycled" automatically What are Reference Variables? correct answers Stores the memory address of an object. We say that the variable "refers" to the object. Example: String s = new String ("Cat"); The variable s is held in the stack and it refers to the location in the heap where "Cat" is stored. What is aliasing? correct answers Having more than one reference variable that refers to the same object. Example: String q = new String("Cat"); String r = q; They are both referencing to the object q, "Cat". So, r == q; is correct because it's point to the location where q is stored.
Geschreven voor
- Instelling
- CMSC 131
- Vak
- CMSC 131
Documentinformatie
- Geüpload op
- 21 september 2023
- Aantal pagina's
- 16
- Geschreven in
- 2023/2024
- Type
- Tentamen (uitwerkingen)
- Bevat
- Vragen en antwoorden
Onderwerpen
-
what two things make up an object
Ook beschikbaar in voordeelbundel