T Interv.NEiew Flashcards
What is composition?
The ability to build functions by using other functions is called composition
what is scaffolding?
Code that is used to assist with development and debugging. Unit test code is an example of scaffolding.
What is the difference between a block and a body?
A block is group of consecutive statements with the same indentation.
A body is a kind of block that is found after a method’s header.
What is an example of definite iteration?
a for loop
What is an example of indefinite iteration?
a while loop
What are collection classes used for?
maintaining lists of objects
What is IList used for?
IList Provides a list of items for a collection along with the capabilities for accessing these items, and some other basic capabilities related to lists of items
What is IDictionary used for?
IDictionary — Similar to IList, but provides a list of items accessible via a key value, rather than an index
Can an interface have a body?
No
An abstract class allows you to create functionality that subclasses _______
inherit (or override??)
Can you apply access modifiers to abstract classes or interfaces, which one?
Only abstract classes
Do you use abstract classes or interfaces to provide multiple inheritance in C#?
Interfaces only
What access modifier must interface members be implicitly implemented with?
public
What is the syntax for explicit implementation?
.
IFile.ReadFile()
Describe an interface
An interface is an empty shell. Only signatures, no bodies. An interface can’t do anything. It’s just a pattern.
Can you define behavior in an interface?
No. Interfaces can only have signatures.
Which constructor would be called first? A base class, or a sub class?
sub class
What is the essential difference between interfaces and abstract classes?
Where you want to define behavior
Is an abstract class an example of a “is-a” relationship, or a “has-a” relationship?
is-a
a Tank is a Vehicle
Are abstract classes or interfaces “implemented”, which one?
interfaces
Are interfaces or abstract methods more expensive to use?
abstract classes
If the proposed base class doesn’t provide default implementations for your methods, is this a reason to choose inheritance or an interface?
interface
If it makes sense to call a method even when no object has been constructed yet, how should that method be defined?
static
Can you override a static method?
no
Does a static method produce a state?
no
If there is some code that can easily be shared by all the instance methods, what should you do with that code?
Extract that code into a static method
Can a static method be garbage collected?
No
Is using static methods is always thread safe?
No
If you have something consuming your classes, and you want to ensure that all of the classes implement the same methods and properties, but not necessarily the same functionality, what would you use?
Interfaces
If you have common functionality you want available in all child classes, where each child class can extend or override the parent class code, what should you use?
you should use inheritance (Abstract classes)
A METHOD without a body is known as?
An abstract method
Can you create an object from an abstract class?
No
What is abstraction?
Data abstraction is the process of hiding certain details and showing only essential information to the user