Classes Definitions Flashcards

1
Q

Describe an array structure clearly identifying:
Three key aspects;
How an array can be instantiated;
How the first item within an array structure can be accessed.

A

Array items of same type.
Items can be accessed by an index numbered from 0 to array length-1.
New array area must be allocated if more items required and array copied to new area.
Array has name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name one exception that can be trapped when developing applications?

A

IOException.
IndexOutOfRangeException.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Exception handling makes use of try / catch blocks.
Define the general structure of the try / catch block.
Give a brief description of the purpose of each section.

A

Try- body of code-jumps to catch blocks on error.
Does not process subsequent statements.
Catch- deal with recovery.
Catch-hierarchical blocks (Exception, if used, is last).
Finally-block of code processed regardless if errors found or not.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain the terms-
new Booking.
DateTime.Now

A

Instantiation of an object of type Booking.
Method call for today’s date from class DateTime.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name three types of check which should be considered for data entry.

A

Describe implementation of Exception Handling with reference to try catch finally.
Many different classes available or inbuilt.
Error messages-example.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe how Exception Handling is implemented in the class design and specify any further classes required.

A

Apply appropriate checks to value before SET of field.
An error causes a throw of an exception object.
Customised class must extend Exception class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe how Exception Handling would be applied to prevent a program crash when an invalid value is entered for a field in the object.

A

Try- surrounding input of value and set of value.
Catch-deals with customised exception.
Finally-tidy up code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain IComparable and indicate why it would be applied to the class.

A

Implements an interface.
To allow comparison of two objects.
Sort an array of objects.
Stimulates multiple inheritance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does public and static do?

A

Public- visibility, allows access by all classes.
Static- single instance- use class name to access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Indicate how you would implement an error trap?

A

Use property setting/implement check

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe how a new telephone number could be handled to ensure the program will not crash.

A

Loop around data entry.
Use try catch.
Try around set of the new telephone number
Catch ClientException.
Output the returned exception message in the catch by messageBox
Set error flag

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does an abstract class differ from a standard base class?

A

Cannot be instantiated.
Can contain abstract and non-abstract methods.
Must be extended.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

A method has been declared abstract in the base class.
What significance will this have to the subclasses?

A

Derived classes must be implemented and overridden.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In the class Results:
public static string GradeLevel (int mark)
What do you understand by the use of the term static for this method?

A

Referenced explicitly by the class name Results.
Referenced implicitly if the class Results is imported.
One occurrence only at Type level.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does a class method differ from a static method?

A

Can be overridden.
Many instances of the method can exist.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Child [] childArray = new Child [60];
Explain this line of code

A

References objects of type Child.
childArray set as array name.
Instantiate array size 60.
Initialised to null.
Creates space in the memory.

17
Q

Describe four ways in which inheritance benefits OOP.

A

Saves time for testing or development.
Multiple interface inheritance allowed.
Implements reusability of code.
Polymorphism uses overriding.
The process of overloading can be used.