cmpt 270 final m.c. (no weekly quizzes)

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards

the major difference between stack memory and heap memory is that the stack is used to store the order of method execution and local variables while the heap memory stores the objects and it uses dynamic memory allocation and deallocation

true or false

true

2
New cards

in java, the default value for a class variable of type int is -1.

true or false

false

3
New cards

instance variables are used to represent an object’s state

true or false

true

4
New cards

subclasses can access private instance variables of the superclass

true or false

false

5
New cards

when writing regression tests, it is ok to directly interact with private variables

true or false

false

6
New cards

a uml use case diagram is considered a behavioural diagram, as opposed to a structural diagram

true or false

true

7
New cards

in Java, the toString() method automatically collects a class’ attributes and generates a formatted Strinag representation of the class

true or false

false

8
New cards

you need to provide the size of an arrayList when you are creatin the arrayList

true or false

false

9
New cards

polymorphism can be used with both inherit super types and implemented supertypes

true or falsea

false

10
New cards

which of the following is not a class found in java’s collection framework

arraylist

hashmap

hashset

dictionary

dictionary

11
New cards

which of the following are not important for a regression test program?

constructing objects are calling methods

displaing the results of the method calls

displaying the values that you expect to get

reading input from the user

reading input from the user

12
New cards

suppose the class coffee extends the class drink. which one of the following assignments is legal?

  • drink x = new drink();

  • coffee y = new coffee();

a) y = x;

b) x = y;

c) y = new drink();

d) new drink() = new coffee();

x = y;

13
New cards

suppose you are to design an inheritance hierarchy with the following classes: mouse, cat, mammal, and tiger. which of these is the superclass?

a) tiger

b) mammal

c) mouse

d) cat

mammal

14
New cards

which programming technique should be used if you want a method to have different behaviour depending on the class of the object that is invoking it?

polymorphism

the instaceof operator

an if-else statement

the getclass method

polymorphism

15
New cards

which of the following java snippets would be used to declare a hashmap that contains items of type exam and is accessed by a key of type string?

a. hashmap<exam> exams = new hashmap<string>();

b. hashmap<t> exams = new hashmap<t>();

c. map<exam, string> exams = new hashmap<exam, string>();

d. map<string, exam> exams = new hashmap<string, exam>();

d. map<string, exam> exams = new hashmap<string, exam>();

16
New cards

when should you delete your testing code from a class?'

if it is a simple class you don’t need to write proper regression tests

when all tests are passed and you know the class wont be changing

your regression tests should never be deleted

after several months without errors it makes sense to delete your tests to make your code easier to read

your regression tests should never be deleted

17
New cards

consider the following code fragment:

Object obj = “CMPT 270”;

System.out.println(ob.length());

which of the following statements are true?

a) the code compiles are runs without issue

b) the code will not compile because the Object class does not have a method called length()

c) the code will not compile because a String object cannot be assigned to something of type object

d) the code will compile but throw an exception

the code will not compile because the Object class does not have a method called length()

18
New cards

instance variables are used to model the attributes of an object

true or false

true

19
New cards

if your code contains an error, there will always be atleast one corresponding fault

true or false

false