CSCI301 Software Development final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Select all statements that are valid for Android activities!

- An activity is usually listed in the AndroidManifest.xml file. - An activity is rather short lived. - An activity has a rather complicated life cycle with different states that show if the activity is running on screen or if it is paused or stopped and so forth.

Calendar and contacts are two examples of ...

... an Android Content Provider.

The Pseudocode Programming Process asks to perform a number of steps when implementing methods. Bring the following steps into the recommended order for the Pseudocode Programming Process.

1) Think it through 2) Write down what code is supposed to do in pseudocode as comments 3) Review your pseudocode 4) Code 5) Review your code

The Manifesto for Agile Software Development values certain items more than others. From the following list of 8 items select the 4 that matter most for Agile Software Development.

1) Working software 2) Individuals and interactions 3) Responding to change 4) Customer collaboration

When it comes to inheritance in Java, which of the following statements are correct?

1. A superclass need not be complete. The class and its missing methods can be declared as abstract. This concept is known as "abstract classes". 2. Inheritance relies on Liskov's substitution principle to work. 3. Inheritance allows classes to share code based on an "is-a" relationship where the subclasses are special cases of a more general super class. 4. In Java, inheritance always results in a hierarchy that takes the form of a tree. The Object class is the root note (most general super class) and all other classes either directly or indirectly inherit from it.

Which of the following documents may serve as a functional specification (the outcome of the analysis phase)?

1. A text with a set of use cases 2. A text with a list of features

Order the following steps such that they describe the common workflow for test driven development.

1. Check out sources & tests from code base. 2. Create test suite or enlarge existing test suite for new product feature. 3. Implement functionality and make software pass tests. 4 Refactor software. 5. Perform regression testing. 6. Check-in software & tests into code base.

Identify the 3 phases of the Scrum method.

1. Outline planning phase that establishes general objectives and designs the overall software architecture 2.Series of sprint cycles, each cycle develops an increment of the system 3. Closure phase wraps up and completes documentation.

UML sequence diagrams have a number of properties. Please indicate which of the following statements are correct. (5)

1. Sequence diagrams allow for object construction (can represent "new Object()") 2. Sequence diagrams are good to show interactions among classes 3. Sequence diagrams are good to show which classes are involved in the execution of a use case 4. Sequence diagrams allow for self calls 5. Sequence diagrams can naturally visualize steps that are ordered in a total order

An object has an identity (thanks to its memory location), a state (thanks to its attributes and fields), and behavior (thanks to its methods). For encapsulation, which of these aspects should be kept secret/private?

1. Some methods should be freely accessible (public), others can be kept secret/private. 2. All attributes of an object should be kept secret/private.

What do you know about Extreme Programming? Pick statements that are correct.

1. With XP you never miss a deadline; you just deliver less content. 2. XP is an incremental software development process designed to cope with change.

Under what circumstances would you consider using UML state diagrams? Please select all of the following sentence completions that are correct. Specify a class whose responsibility is ...

1. checking of a PIN number for authentication 2. operating a vending machine. 3. connecting to a remote server over an unreliable network

The percentage of large software development projects (budget exceeds $1M) that fail is in the following range (based on a Gartner study of 2012):

20-40 percent (substantial)

Which class relationship between 2 classes A and B does inheritance imply?

A is a B

The Object class has a method equals(Object o). We implement a new class Example and write code for a method equals(Example e) in it. Let ex be a variable of type Example, i a variable to type Integer, and o a variable of type object.

A line of code ex.equals(o) calls for the equals method of the Object class, a line of code ex.equals(i) calls for the equals method of the Object class, if ex == null then ex.equals(o) must lead to a NullPointerException, a line of code ex.equals(ex) calls for the equals method of the Example class

A class definition can include

A list of its interfaces Definitions of fields Its direct superclass Definitions of methods

What do you know about race conditions? Select all statements that are correct.

A race condition can be prevented by identifying shared data and by controlling/synchronizing concurrent thread access to all shared data, a race condition occurs if the effect of multiple threads on shared data depends on the order in which threads are scheduled

What do you know about Strings in Java?

A string supports a method length(). The String class is a subclass of Object. For two strings x and y, z = x + y results in a string z as the concatenation of x and y.

What do you know about Interfaces in Java?

A variable can be of interface type. A class can have only one super class but it can implement many interfaces. An interface is a list of method signatures (plus some optional definitions of constant values).

Given the following brief description of requirements: The banking system supports a variety of accounts, for example a checking account. Each customer has at least one checking account that allows the customer to pay bills within the existing credit limit. Preferred customers enjoy unlimited credit for their accounts. The designer decides to have a customer class and checking account class. What is the relationship between the customer class and the checking account class?

Aggregation

An object is instantiated with the help of the new() method. Example: House x = new House() ; Variable x is a reference to the new House object we instantiated. Where is the new House object located (where is the memory located that is needed for its representation)?

Always on the heap

Which statements are true about an interface?

An interface can inherit from another interface and in that way extend that interface, an interface can contain a list of method signatures and constants, a variable can be of interface type

What are valid reasons to implement code for automated tests before implementing code?

Automated testing allows you to do testing during and after coding very early, it minimizes the time between the moment when the error is introduced and the moment one can recognize its presence with a test, it requires you to think about requirements and design before you code and thus helps to avoid making mistakes in the first place

Java supports a for loop of the form for(A; B; C){D}

B is a boolean condition that must be true to continue with the iteration C is usually used for a command the makes the iteration counter progress towards termination If D is a single command, one can omit the braces {}. A is usually used to declare and/or initialize a variable to count the iteration A is optional and can be an empty statement (A;B;C);{D} is an error pattern C is optional and can be empty

The class Salad has a public field root. We implement a subclass of Salad named Iceberg that must access the root field. How can we do this?

Because the root field is public, it can be directly accessed similar to any field in Iceberg

What is the meaning of the "&" operator in an expression such as A & B?

Bitwise AND if A, B are of type int

How do you call a method getX() of a superclass Y in your current class Z if you overwrite getX() in Z?

By calling super.getX()

The first "C" in CRC cards stands for

Class

If a variable v of interface type I refers to an object of type O then...

Class O or one of its superclasses must implement I, polymorphism denotes the fact that a method call v.m() can execute code that may differ with the type of object that v really refers to, we can call any method m() as v.m() whose signature is listed in I

The last "C" in CRC cards stands for

Collaborators

Which type of comments is the most valuable?

Comments that tell me the purpose for some code, that tell what the code should do.

What do you know about Arrays?

Comparing arrays is a common source of errors in programming with arrays. Comparing arrays with "==" is only true if one compares the array to itself. An array is a subclass of Object. Accessing array elements outside of its bounds leads to an exception. It depends on the exception handling of this leads to program termination or not. Array entries have an indexation ranging 0,...,n-1 if the array has n entries Comparing arrays x and y with x.equals(y) has the same effect as using "x == y" .

Attach additional responsibilities to an object dynamically. Provide a flexible alternative to sub-classing for extending functionality.

Decorator

True or False: Branch coverage does not check cases in switch statements.

False

True or False: Condition coverage checks if for an if statement both branches are covered.

False

True or False: With full condition coverage, branch coverage is guaranteed.

False

What are potential benefits of using multiple threads in Java programming?

Faster execution due to possibly better use of CPU cycles even on a single CPU, single core architecture, for a user interface, having a UI thread to handle the user interaction and other threads to do the background work is beneficial, for some applications, the software design may clearer with multiple threads, faster execution if architecture has a CPU with multiple cores

Mark principles for good software design on the following list:

Favor composition over inheritance Encapsulate what varies Program to an interface

Test Description - Unit Testing

Find errors by checking isolated pieces, such as a single class or a single method

Test Description - Integration Testing

Find errors by looking at separate components (classes, methods) when they work together

Test Description - System Testing

Find errors when running the full system in its environment

Select the three fundamental steps in developing software that we can not avoid regardless of the way the project is managed and organized.

Implementation Analysis Design

Given the following brief description of requirements: The banking system supports a variety of accounts, for example a checking account. Each customer has at least one checking account which allows the customer use the account to pay bills within the existing credit limit. Preferred customers enjoy unlimited credit for their accounts. What is the relationship between the checking account class and the account class?

Inheritance

What is the difference between the state and strategy pattern?

Intentions are different.

Which statement describes Liskov's substitution principle?

It applies to inheritance: you can use a subclass object whenever a superclass object is expected.

For a method that is not static in some class that you programmed: What are possible ways for the code inside your method to access data outside of its scope? Let's ignore the additional impact of privacy settings for this question.

It can access any instance variable of its own class but each instance has its own copy of that variable and it does not share that with other instances. It can access its parameter values. It can access static variables located somewhere in the code base.

When calculating the expected answer for a pass/fail criterion in a test case

It is usually reasonable to pick input values that are representative but also easy to calculate.

Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Iterator

In Java, which of the following steps do one needs to do to declare and run a thread?

Let the thread begin working by calling its start() method, implement a class that implements the Runnable interface or inherits from the Thread class, instantiate a thread object and assign a runnable object to it

You can use a superclass object whenever a subclass object is expected.

None of the other answers is correct

Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Observer

Test Description - Black Box Testing

Performs tests based on a public interface description and without knowing the details of the implementation

Test Description - White Box Testing

Performs tests that developed with detailed knowledge of the actual source code

When you code the run() method for a thread, this is a good way to prepare your code for external thread termination

Position sleep() method calls for a short duration as necessary in my code. The actual code to wrap up and finalize gets into a catch block for an interrupted exception.

Object oriented programming languages allow us to combine data and algorithms into objects. What are the implications of this?

Relating similar objects such that they can share data and algorithms Associating an object with a set of roles that it is able to perform Retaining a local control over access to data is possible

The "R" in CRC cards stands for

Responsibilities

Test Description - Regression Testing

Retest to see if code still works and passes the tests it passed before changes were made

A thread scheduler groups the threads it needs to schedule into 3 categories. Which are they?

Running: threads that are currently running, Runnable: ready to run but not running, Blocked: not ready to run

The SOLID principles in design are

Single responsibility principle, open/closed principle, Liskov's substitution principle, interface segregation principle, dependency inversion principle

Which statement describes the open / closed principle?

Software entities should be open for extension, closed for modification.

Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.

State

Select all statements that are correct (testing)

Statement or Branch coverage is used in practice, MC/DC is required for reliable systems, for instance in aviation

Define a family of algorithms, encapsulate each one, and make them interchangeable. Let the algorithm vary independently from clients that use it.

Strategy

Which statements are correct for the Pseudocode Programming Process?

The Pseudocode Programming Process boils down to writing detailed comments first at a level of abstraction that is higher than the actual code, pseudocode makes code reviews easier, the key idea is to separate the detailed design of a method from the coding of a method, the Pseudocode Programming Process recommends that you review and iterate when developing the pseudocode description

When executed, code can access memory locations to read or write data. To support a life cycle for data (creation, read/write access, deletion), we can allocate memory and release memory such that it can be reused for other purpose.

The command to allocate memory in Java is "new" and followed by a constructor method call.

Use cases are often closely related to each other and share a lot of actions. From the following set of use cases, pick the one that would naturally become the base line. All others would the become variations of it.

The customer selects "transfer funds into account" option, chooses an account to transfer the funds from, chooses an amount, confirms the transaction, the transaction starts, the funding source has sufficient funds, the transfer is performed and successfully completed. The account balance is updated.

If we write a line of code "Age a = new Age(123);" in some method and that line gets executed at runtime, then

The newly created object of type Age resides on the heap. The Age class must have a constructor method of signature Age(int a) that is also called. Variable a is located in the current stack frame.

If we let multiple threads operated and write output to the console, we get an idea how the JVM thread scheduler works.

The scheduler can schedule threads in many ways. As a developer, I should be expecting any possible order of execution.

In a constructor method, the first line of code either explicitly calls a constructor method of the superclass or the compiler automatically inserts such a call but for the default constructor method that has no parameters.

This is right because our subclass needs properly initialized instance variables that are inherited from the superclass.

An object is said to have a state.

This is thanks to its fields which can memorize what happened to the object so far.

If thread A waits for thread B to deliver results when B terminates. What is the best way to implement this?

Thread A calls B.join()

How can you exchange information between two threads?

Threads within the same process access the same memory address space. They communicate via shared objects.

True or False: A general shortcoming of coverage criteria is that a 100 percent coverage does not necessarily mean the code is correct.

True

True or False: Data flow coverage checks if define-used pairs are covered.

True

True or False: Testing is never complete even if coverage is at a 100 percent.

True

True or False (and elaborate): A test case should contain documentation on what is the correct answer and why that answer is correct.

True, because developers don't trust a test if it fails

What is the minimum number of test cases needed for condition coverage if the statement is "if (A || B || C) then { /* more code */ }" ?

Two

Pick the most appropriate statement to describe what UML class diagrams visualize.

UML class diagrams show classes and their relationships

A class Employee has a private field social security number. We implement a subclass of Employee named Manager that must access the social security number field. How can we do this?

We can not directly access private fields of a superclass; we would need a method such as getSSN() in the Employee class for that.

How can you transfer computed results out of the scope of a method that is not static?

With the help of a parameter that refers to a mutable object. With the help of the return value. With the help of instance variables of the method's class. With the help of accessible static variables somewhere in the code base.

Which component do you use in your code if your app needs to recognize that the system is low on power and will shut down?

a Broadcast Receiver

A Use case is...

a sequence of actions. Each action is an interaction between an actor and a computer system. Each action yields a result and each result has a value to one of the actors.

Code is executed as a sequence of elementary, basic steps. Our (Java) programs need to specify such as sequence, so the (Java) language must have typical control flow operations. Control flow operators are

choice or conditional execution sequence (;) loops

When it comes to managing complexity in software designs, our main strategy is

divide and conquer

A class can have several methods of same signature but with different names.

false

A class can not have multiple constructor methods as they would all have the same name.

false

The waterfall process model is called waterfall because it describes how the code is developed in a top-down manner as water falls down and not bottom-up.

false

Select the primitive types in Java from the following list.

float char int

When it comes to code-level documentation, the main contributor ...

is not comments, it is good programming style.

An object is said to have an identity because

it resides in memory and that memory address makes it unique

The command to compile a Java code base into intermediate byte code is

javac

The key concept in software design is to ...

minimize complexity.

Delivering the perfect software product on time is difficult because

the designer is not able to match the spec with the design accurately enough the client does not know precisely what he/she wants, changes his/her mind and priorities over time the developer fails to implement the design without missing anything, misunderstanding anything or without making accidental programming errors delivering a complete, error-free, consistent specification is a challenge for the analyst the end user may not find the human-computer interface being a good fit for the tasks he/she needs to accomplish with the software the analyst does not necessarily fully understands the task (not a subject matter expert)

A running Java program terminates naturally if

the main method returns from execution and all of its threads terminate

A JVM loads byte code for individual classes as needed during execution.

true

Agile Software Development's answer to challenges in software development is to build software incrementally with short iteration cycles and keeping development aligned with changing needs on the client side.

true

Hardware has a memory hierarchy with volatile and persistent levels. This implies that code needs to distinguish between those. The address space of a process with its objects resides in volatile memory such we can directly access its content. When it comes to accessing data that is in persistent storage we need to access the file system and load data from it.

true

In Java programming, the format of the source code (indentation, paragraphs, end of line) follows common practice rules to make it easier for humans to read the code. The format does not matter for the compiler.

true

The import statements are a short cut to avoid typing full class names with package names in code.

true

Thread methods that one can call to influence the scheduler are

yield() to suggest a switch to the scheduler and sleep(long millisecond) to make the thread pause for some time


Set pelajaran terkait

(Customer Service) Chapter #1 Vocabulary

View Set

NCLEX Ch 26 Documentation and Informatics

View Set

Chapter 2 Theories and Treatment of Abnormality

View Set

Health: Chapter 10: Head, Eyes, Ears, Nose, and Throat

View Set

INTERNATIONAL BUSINESS LAW CHAPTER 15 THE EU

View Set