Question: C# 1. Casting from a base type variable to a derived type variable is always safe. true false 2. Inheritance (deriving one class from another)
C#
1. Casting from a base type variable to a derived type variable is always safe.
true
false
2. Inheritance (deriving one class from another) is what type of relationship?
is-a
has-a
looks-like-a
acts-like-a
3. Given a class "Person," how would you derive a class "Student" from it?
class Student : Person
class Person : Student
class Student = Person
class Student : class Person
4. If a byte is 8 bits, how many bits are in an int variable?
8
16
32
64
5. A child class has direct access to what fields and methods of its parent?
public
protected
private
public, protected, -and- private
public -and- protected
6. When an instance of a child class is made, what order are the constructors called in?
first the child class, then the base class
only the child class
first the base class, then the child class
only the base class
7. Which of these methods sets up default/optional parameters correctly?
void foo(int x, int y, int z)
void foo(int x = 0, int y, int z)
void foo(int x, int y = 0, int z = 0)
void foo(int x, int y = 0, int z)
8. Which container type is used to store key-value pairs
Dictionary
Linked List
List
Array
int
string
9. In .NET, when you pass parameters by reference, you are...
using pointers like C++
making a copy of the data and passing it to the method
creating a reference type variable on the heap
making an alias of the variable used in calling the method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
