EVENT DRIVEN PRELIM

full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/34

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

35 Terms

1

D. Value

It can be accessed in the hashtable when a key is

specified.

A. Iterator

B. List

C. Store

D. Value

2

A. add-remove

Which event accessors are similar to get and set

accessors used with properties?

A. add-remove

B. push-pop

C. insert-delete

D. enqueue-dequeue

3

C. public delegate int delegateName();

Which of the following syntax is correct when

declaring a delegate?

A. public delegate int delegateName[]():

B. delegate string delegateName(){}:

C. public delegate int delegateName();

D. public delegate delegateName int();

4

B. Event Handler

This represents a method that is invoked when an

event-occurs.

A. Exception Handling

B. Event Handler

C. Method Handler

D. Event Class

5

C. delegate

This keyword is used to declare a delegate in a

class.

A. new

B. static

C. delegate

D. del

6

A. SortedList

What type of collection is used to arrange the key

values and is considered a combination of ArrayList

and Hashtable?

A. SortedList

B. Stack

C. Queue

D. BitArray

7

B. Sort()

What method can be used to arrange the elements

in the list object?

A. Peek()

B. Sort()

C. ListSort()

D. Pop()

8

C. Remove()

Which method is used to delete an item from an

ArrayList?

A. Delete()

B. GetIndex()

C. Remove()

D. RemoveByIndex()

9

A. -=

Which of the following is used to remove an event

from a class?

A. -=

B. --

C. ---

D. =-

10

C. Event

This is usually known as a task initiator.

A. Function

B. Exception

C. Event

D. Delegate

11

A. Queue

Which of the following classes represents the 'First

In, First Out' collection of objects?

A. Queue

B. Stack 

C. ArrayList

D. BitArray

12

C. ArrayList

This is known as an ordered collection of objects.

A. Hashtable

B. Dictionary

C. ArrayList

D. Iterator

13

D. Delegate

It is a type that safely encapsulates a method.

A. Event

B. Inheritance

C. Partial

D. Delegate

14

C. Remove()

Which of the following methods is used to delete an

element in a SortedList by specifying a key?

A. Clear()

B. ContainsKey()

C. Remove()

D. RemoveAt()

15

C. System.Collections.Generic;

Which namespace contains several generic

collection classes?

A. System.Generic.Collections;

B. System.Collections.Standard.Generic;

C. System.Collections.Generic;

D. System.Generic;

16

A. void RemoveAt(int index)

Which method is used to remove the specified

element by calling its index in SortedList?

A. void RemoveAt(int index)

B. void Remove(int index)

C. void Clear(int index)

D. void Dequeue(int index)

17

B. Not Available!

What will be the output once the code below is

compiled and executed?

public void AddToHash()

{

hashltem.Add("Coffee", 8);

hastltem.Add("Sugar",25);

}

public void RemoveToHash()

{

string varValue = "Apple";

if(hashltem.ContainsKey(varValue))

{

Console.WriteLine("Removed");

}else

{

Console.WriteLine("Not Available!");

}

}

A. Removed

B. Not Available!

C. Syntax Error

D. FormatException

18

B. varList.Sort()

18. Which of the following syntax is correct in

categorizing the element in the list object?

A. varList.Categorize()

B. varList.Sort()

C. varList.SetFrom()

D. varList.ListSort()

19

C. Stack objStack = new Stack():

objStack.Push("Ball"):

Which of the following syntax is used to add an

object in the stack collection?

A. Stack objStack = new Stack();

objStack.Add("Ball");

B. Stack objStack = new Stack();

objStack.Enqueue("Ball*);

C. Stack objStack = new Stack():

objStack.Push("Ball"):

D. Stack objStack = new Stack();

objStack.Peek("Ball");

20

D. These are chosen when a class needs only one

(1) implementation of the method.

Which of the following statements is TRUE about

interfaces?

A. These are faster to execute but slower to get.

B. These can reference any method of a class that

provides arguments and return types. 

C. These are safe callbacks and only have a

declaration. 

D. These are chosen when a class needs only one

(1) implementation of the method.

21

B. srtLst.Add("Mike",24); 

Which of the following codes is correct in adding an

item in SortedList?

A. srtLst = Add("Banana");

B. srtLst.Add("Mike",24); 

C. srtLst = Add("Coffee", 98);

D. srtLst.Add(95);

22

A. Queue<T> varName = new Queue<T>();

Which of the following is in the correct format in

declaring a generic Queue?

A. Queue<T> varName = new Queue<T>();

B. Queue<T> varName = new Queue();

C. Queue varName = new Queue<T>;

D. Queue(T) varName = new Queue<>(T):

23

C. ArrayList names = new ArrayList();

Which of the following has the CORRECT general

syntax of defining an array?

A. ArrayList names = new ArrayList;

B. ArrayList names = ArrayList():

C. ArrayList names = new ArrayList();

D. ArrayList names = ArrayList;

24

C. public static event delegateName eventName;

Which of the following syntax is correct when

declaring a simple event class?

A. public static event eventName;

B. public static delegateName eventName;

C. public static event delegateName eventName;

D. Public static event DelegateName;

25

A. ArrayList vartist = new ArrayList():

varList.Add("Cake");

Which of the following syntax is CORRECT in

adding an object in an ArrayList?

A. ArrayList vartist = new ArrayList():

varList.Add("Cake");

B. ArrayList varList = new ArrayList():

varList.Push("Cake");

C. ArrayList varList = new ArrayList();

varList.Pop("Cake");

D. ArrayList varList = new ArrayList();

varList.Insert("Cake");

26

A. DelegateName dn = new

DelegateName(ClassName.MethodName);

Which of the following syntax is correct when

instantiating delegates?

A. DelegateName dn = new

DelegateName(ClassName.MethodName);

B. DelegateName dn;

dn(ClassName.MethodName);

C. DelegateName dn = ClassName;

D. DelegateName dn = MethodName;

27

A. James Cruz

Which of the following outputs is correct when you 

compile the program?

public delegate string DelStringValue(string val);

public string GetFullName(string fullName)

{

return fullName;

}

private void btnConfirm_Click(object sender,

EventArgs e){

DelStringValue stringVal = new

DelStringValue(GetFullName);

Console.WriteLine(stringVal("James Cruz"));

}

A. James Cruz

B. The variable 'ex' is declared but never used.

C. Format Exception

D. No overload for 'Form1.GetFullName(string)'

matches delegate 'DelTotal'

28

D. bool ContainsKey()

This method is used to check if the SortedList,

contains the specified key that returns a boolean

value true.

A. bool KeyValues

B. bool Keys

C. bool Contain() 

D. bool ContainsKey()

29

C. ArrayList class

Which of the following is dynamic since items can

be added and removed from the specified index

location?

A. foreach loop

B. One-dimensional array

C. ArrayList class

D. Two-dimensional array

30

B. A delegate can call any method as long as its

signature matches.

Which of the following statements is TRUE when

using a delegate class to encapsulate the methods? 

A. A delegate cannot be invoked; it can only be

declared and instantiated.

B. A delegate can call any method as long as its

signature matches.

C. A class that implements a delegate can

implement all the methods associated with it.

D. A delegate can implement a method only once;

otherwise, a generic delegate is used.

31

D. public delegate Y DelegateName<Y>(Y arg);

Which of the following syntax is correct in declaring

a generic delegate?

A. public delegate DelegateName<X>(int arg);

B. public delegate A DelegateName<A>(X arg);

C. public delegate A DelegateName<>();

D. public delegate Y DelegateName<Y>(Y arg);

32

A. public event DelegateName EventName

{

add

{

delName += value;

}

remove

{

delName -= value;

}

}

Which of the following syntax is correct when using

the methods add and remove?

public DelegateName delName;

A. public event DelegateName EventName

{

add

{

delName += value;

}

remove

{

delName -= value;

}

}

B. public event EventName{

add

{

delName += value;

}

remove

{

delName -= value;

}

}

C. public event DelegateName()

{

  add(delName += value);

    remove(delName -= value);

}

D. public event DelegateName EventName()

{

     add(delName += value);

     remove(delName -= value);

}

33

A. Paul Cruz 230

What will be the output when the program is

compiled and executed, assuming the method

signatures match the delegate?

public delegate Val DelValues<Val>(Val arg);

private void btnShow_Click(object sender,

EventArgs e) 

{

    DelValues<string> fullName = new

DelValues<string>(Info.GetFullName);

    DelValues<int> totalAmount = new

DelValues<int>(Compute.GetTotalAmount);

   Console.WriteLine(fullName("Paul Cruz"));

   Console.WriteLine(totalAmount(230));

}

A. Paul Cruz 230

B. No overload for 'Form1.GetFullName(string)'

matches delegate DelValues

C. No overload for 'Form1.GetTotalAmount(string)'

matches delegate DelValues

D. The variable "Val' is declared but never used.

34

C. No overload for

'Form1.GetTotalAmount(double)' matches

delegate 'DelTotal'

Which of the following outputs is correct when you

compile the program?

public delegate int DelTotal(int total);

public int GetTotalAmount( double totalAmount);

{

    int total = Convert.Tolnt32(totalAmount);

return total;

}

private void btnAnswer_Click(object sender,

EventArgs e)

{

  try{

   DelTotal delTotal = new

DelTotal(GetTotalAmount);

Console.WriteLine(delTotal(150).ToString());

} catch(Exception ex)

Console.WriteLine("Error in Delegate?");

}

}

A. Error in Delegate!

B.150

C. No overload for

'Form1.GetTotalAmount(double)' matches

delegate 'DelTotal'

D. The variable 'ex' is declared but never used.

35

C. EventName += new

DelegateName(ClassName.StaticMethod);

Which of the following codes is correct when adding

an event?

A. EventName = new

DelegateName(ClassName.StaticMethod);

B. EventName +=(ClassNAme.StaticMethod);

C. EventName += new

DelegateName(ClassName.StaticMethod);

D. EventName += DelagateName.ClassName;