1/71
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
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
in java, the default value for a class variable of type int
is -1.
true or false
false
instance variables are used to represent an object’s state
true or false
true
subclasses can access private instance variables of the superclass
true or false
false
when writing regression tests, it is ok to directly interact with private variables
true or false
false
a uml use case diagram is considered a behavioural diagram, as opposed to a structural diagram
true or false
true
in java, the toString() method automatically collects a class’ attributes and generated a formatted string representation of the class
true or false
false
you need to provide the size of an arrayList when you are creatin the arrayList
true or false
false
polymorphism can be used with both inherit super types and implemented supertypes
true or false
true
which of the following is not a class found in java’s collection framework
a) arraylist
b) hashmap
c) hashset
d) dictionary
dictionary
which of the following are not important for a regression test program?
a) constructing objects are calling methods
b) displaing the results of the method calls
c) displaying the values that you expect to get
d) reading input from the user
reading input from the user
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;
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
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?
a) polymorphism
b) the instaceof operator
c) an if-else statement
d) the getclass method
polymorphism
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
when should you delete your testing code from a class?'
a) if it is a simple class you don’t need to write proper regression tests
b) when all tests are passed and you know the class wont be changing
c) your regression tests should never be deleted
d) 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
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()
software development is all about learning a programming language
false
object oriented programming
a program consisting of classes and objects organized to manage the complexity of large-scale systems
procedural programming
a program consisting of methods/functions calling each other
method
implements behaviors relevant to the purpose of the system
field or attribute
stores data relevant to the purpose of the system
container object
data structure to store entities
entity object
model of a real-world thing in an application
interface object
facilitates communication between the system and the outside world
control object
organizes computation or flow of the program
a uml class diagram is a behavioral diagram
true or false
false
given 3 classes: plant, tree, flower, which of the following best describes their relationship to one another
inheritance
suppose you have 2 classes: house, and wall, where the house is a container of wall objects. which of the following best describes this relationship?
composition
suppose you have 2 classes: book, and bookshelf. which of the following best describes the relationship between these 2 classes?
aggregation
suppose you have 2 classes: hammer and nail, which of the following best describes the relationship between these 2 classes
association
which principle should be used if you want a method to have different behaviour depending on the specific class the method is being invoked on
polymorphism
which of the following statements describes an inheritance relationship?
a textbook is a book
interfaces and inheritance are different name’s for the same concept
true or false
false
using uml class diagrams you can express relationships between two classes. which of the following cannot be expresed in a uml diagram?
polymorphism
encapsulation
grouping related variables and functions together to reduce complexity and increase reusability
polymorphism
refactor ugly if and switch / case statements
inheritance
eliminate redundant code
abstraction
hide details and shows the essentials; isolate the impact of changes
which of the following data types is not a primitive data type in Java
a) string
b) double
c) boolean
d) int
string
all data types in java are references to data allocated on the heap
true or false
false
if you wanted to store measurement data, which Java data type is recommended?
double
Just like in Python, single quotes (' ') and double quotes (" ") are both used to denote a String literal.
true or false
false
Which of the following for loops is correct syntax in Java?
for(int i=0; i<10; i++);
{
System.out.println("Hello");
}
for(int i=0; i<10; i++)
{
System.out.println("Hello");
}
for(int i in Range(10))
{
System.out.println("Hello");
}
for(int i=0, i<10, i++)
{
System.out.println("Hello");
}
for(int i=0; i<10; i++)
{
System.out.println("Hello");
}
What would be the output from the following code snippet?
int x = 10;
int y = 4;
if(x >= 10)
{
System.out.println(x/y);
}
else
{
System.out.println(y/x);
}
a) 2
b) 2.5
c) 0.4
d) 0
2
Assume you have the following String declarations. Which of the following expressions evaluate to true? (select all that apply)
String s1 = "Hello";
String salutation = "Hi";
String howdy = "hELLo";
String greeting = new String("Hello");
a) s1.equals(howdy);
b) s1.equals(greeting);
c) s1 == greeting
d) s1.equalsIgnoreCase(howdy);
e) s1.compareTo(salutation);
s1.equals(greeting); s1.equalsIgnoreCase(howdy);
what does a toString() method do in Java?
it allows a programmer to define a String representation of their class
the tree class does not have an explicit ‘chopDown’ method. which of the following describe the chopDown functionality in the system
a) the Tree object's height is set to 0
b) the Tree object has a boolean variable named 'isDead', which is set to true
c) the Tree object's memory is manually deallocated using free()
d) the Tree variable is set to null
the Tree variable is set to null
why doesn’t the Tree class have a setter/mutator to set the height attribute?
a) it does have one, the method grow() acts as a mutator
b) it doesn't need one, because the height attribute is public so any class can change it directly
c) it does have one, the method getHeight() also sets the height attribute
d) it doesn't need one, because the height attribute should never change
it does have one, the method grow() acts as a mutator
which class acts as the main/client program
a) treePlanter
b) inventory
c) forest
d) tree
treePlanter
the lecture followed a specific development process. Which of the following steps was omitted from the lecture (for now)?
a) Implementing/coding methods
b) UML
c) JUnit Testing
d) Creating stub classes/methods
e) Documentation
JUnit Testing
in the development process followed in the lecture, which of the following steps was last?
a) Creating stub class/methods
b) Implementing/coding methods
c) UML
d) Unit Testing
e) Documentation
Implementing/coding methods
debugging
inferring the cause of undesired behavior or incorrect results
fault
your program exhibits behaviour that is not intended / an undesired behaviour or incorrect result
error
the “thing” that causes a fault / the cause of an undesired behaviour or incorrect result
validation
any method to increase confidence in the correctness of a software system
failure
inability of the system to do what is required
coverage
how much of the code is tested
manual testing
a human types some input to a program
automated testing
the computer runs a script performing the tests
which of the following statements about the relationship between errors and faults is FALSE?
a) it's possible for one error to produce multiple faults
b) if there is no error in the code, there are no faults
c) it's possible for code to have an error but produce no faults
d) it's possible for a fault to be observed, but no error to cause it
it's possible for a fault to be observed, but no error to cause it
when should you delete your testing code from a class?
your regression tests should never be deleted
For CMPT 270, where will you be writing your unit tests?
In the static main method of the class being tested
when writing regression tests, we should print the status of each test to the console.
true or false
false
using the inheritance structuer discussed in the lecture, assume you have a container of type Water Monster. Which of the following types could be stored inside the container?
a) squiiirtle
b) starfishy
c) peekatu
d) monster
e) electric monster
f) water monster
squiirtle, starfisgy, water monster
effective use of polymorphism is good because it increases coupling in a software system
true or false
false
which keyword is used to indicate inheritance in java?
extends
polymorphism can be used with both inherited super types and implented interface types
true
which of the following methods are inherited from the Object class?
a) getClass()
b) equals()
c) scanner.readInt()
d) System.out.println()
e) attack()
f) toString()
getClass(), equals(), toString()
the downside to polymorphism is that once you have a container of the supertype, it is impossible to convert an onject back to its original type
true or false
false
which of the following are a benefit of polymorphism (select all that apply)
a) it reduces coupling
b) it can reduce the amount of code you need to write
c) it makes yout code simpler and more concise
d) it can make your code more flexible / adaptable
e) all of the above
all of the above
which keyword is used to define that a class uses an Interface in Java?
implements