Because the root field is public, it can be directly accessed similar to any field in Iceberg
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?
Private fields of a superclass cannot be directly accessed, so a retrieval method in the Employee class, such as getSSN(), must be used
The Employee class has a private field socialSecurityNumber; a subclass of Employee named Manager must access the social security number field. How can this be done?
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
If a variable v of interface type I refers to an object of type O then...
This is right because our subclass needs properly initialized instance variables that are inherited from the superclass.
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.
Single responsibility principle, open/closed principle, Liskov's substitution principle, interface segregation principle, dependency inversion principle
These are the SOLID principles in design
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) cal
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. What is true of this
None of the other answers is correct
You can use a superclass object whenever a subclass object is expected.
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
These statements are true about interfaces
By calling super.getX()
How do you call a method getX() of a superclass Y in your current class Z if you overwrite getX() in Z?
A is a B
Which class relationship between 2 classes A and B does inheritance imply?
Running: threads that are currently running, Runnable: ready to run but not running, Blocked: not ready to run
The three categories that a thread scheduler groups the threads it needs to schedule into
Threads within the same process access the same memory address space. They communicate via shared objects.
How can you exchange information between two threads?
Thread A calls B.join()
If thread A waits for thread B to deliver results when B terminates. What is the best way to implement this?
The scheduler can schedule threads in many ways. As a developer, I should be expecting any possible order of execution.
If we let multiple threads operate and write output to the console, we get an idea how the JVM thread scheduler works.
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
In Java, these steps need to be completed in order to declare and run a thread
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 applicati
These are the potential benefits of using multiple threads in Java programming
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 s
This is true of race conditions
yield() to suggest a switch to the scheduler and sleep(long millisecond) to make the thread pause for some time
These are the thread methods that one can call to influence the scheduler
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.
When you code the run() method for a thread, this is a good way to prepare your code for external thread termination
True
True or False: A general shortcoming of coverage criteria is that a 100 percent coverage does not necessarily mean the code is correct.
True, because developers don't trust a test if it fails
True or False (and elaborate): A test case should contain documentation on what is the correct answer and why that answer is correct.
False
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.
True
True or False: Data flow coverage checks if define-used pairs are covered.
Statement or Branch coverage is used in practice, MC/DC is required for reliable systems, for instance in aviation
The following is correct about testing
True
True or False: Testing is never complete even if coverage is at a 100 percent.
False
True or False: With full condition coverage, branch coverage is guaranteed.
It is usually reasonable to pick input values that are representative but also easy to calculate.
When calculating the expected answer for a pass/fail criterion in a test case
Two
What is the minimum number of test cases needed for condition coverage if the statement is "if (A || B || C) then { /
more code
/ }" ?
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
What is the recommended order of steps 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 codi
The following is true about the Pseudocode Programming Process
Find errors by checking isolated pieces, such as a single class or a single method
Test Description - Unit Testing
Find errors by looking at separate components (classes, methods) when they work together
Test Description - Integration Testing
Find errors when running the full system in its environment
Test Description - System Testing
Retest to see if code still works and passes the tests it passed before changes were made
Test Description - Regression Testing
Performs tests based on a public interface description and without knowing the details of the implementation
Test Description - Black Box Testing
Performs tests that developed with detailed knowledge of the actual source code
Test Description - White Box Testing
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
These are valid reasons to implement code for automated tests before implementing code