EVENT DRIVEN MIDTERM

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

C. Main Thread

This is the first thread to be performed in a process.
A. Parent Thread
B. Child Thread
C. Main Thread
D. Start Thread

2

B. ApplicationException

Which basic type of exception is user program-
generated?
A. ArithmeticException
B. ApplicationException
C. SystemException
D. ThreadException

3

B. Unstarted

In this thread state, the thread is created within the
CLR but is not in progress.
A. Ready
B. Unstarted
C. WaitSleepJoin
D. Blocked

4

B. ThreadState

What property is used to get the value that contains
the states of the recent thread?
A. Priority
B. ThreadState
C. CurrentThread
D. IsAlive

5

B. System.Threading

Which namespace Includes the Thread class?
A. System.Multithread
B. System.Threading
C. System.Multithread.Thread
D. System.Threaded

6

D. OutOfMemoryException

Which exception is thrown when the available
memory is too low to accommodate?
A. LowMemoryException
B. OverflowException
C. IndexOutOfRangeException
D. OutOfMemoryException

7

B. Running

This thread state indicates that a thread is at the
time of execution after invoking its Start method.
A. Ready
B. Running
C. Started
D. WaitSleepJoin

8

B. Common Language Runtime

What does CLR stand for?
A. Computer Language Running
B. Common Language Runtime
C. Common Languages Running
D. Computer Languages Runtime

9

D. Stopped

This is the state when the thread has completed its
task.
A. Blocked
B. Started
C. Unstarted
D. Stopped

10

C. FormatException

This exception occurs when the format of the
argument is invalid.
A. InvalidFormatException
B. StackOverflowException
C. FormatException
D. OutOfFormatException

11

B. ArgumentException

Which of the following exceptions is thrown when an
argument inside the method is invalid?
A. InvalidException
B. ArgumentException
C. InvalidMethodException
D. InvalidArgumentException

12

A. IndexOutOfRangeException

This exception occurs when attempting to index an
array through an index that is greater than the
maximum length of the index.
A. IndexOutOfRangeException
B. IndexRangeException
C. ArgumentRangeException
D. FormatRangeException

13

C. Name

This property is used to set the name of the thread.
A. IsName
B. ThreadName
C. Name
D. SetName

14

C. StackOverflowException

This exception occurs when the execution stack is
exhausted by having too many pending method
calls.
A. OutOfMemoryException
B. IndexOutOfRangeException
C. StackOverflowException
D. ArgumentException

15

A. CurrentThread

This is used to retum the currently executing thread.
A. CurrentThread
B. Running
C. IsBackground
D. Name

16

B.
try
{
Console.Write(x + " ");
Thread.Sleep(1000);
}
catch(ThreadAbortException ex)
{
if((int)ex.ExceptionState == 0)
{
Thread.ResetAbort();
}
}

  1. Which of the following is the correct syntax to
    withdraw an abort request for the ongoing thread?
    A.
    try
    {
       Console.Write(x + “ “ );
       Thread.Sleep(1000);
    }
    catch(ThreadAbortException ex)
    {
        if((int)ex.ExceptionState == 0)
        {
           Thread.Reset():
        }
    }
    B.
    try
    {
    Console.Write(x + " ");
    Thread.Sleep(1000);
    }
    catch(ThreadAbortException ex)
    {
    if((int)ex.ExceptionState == 0)
    {
    Thread.ResetAbort();
    }
    }
    C.
    try
    {
    Console.Write(x + “ “ );
    Thread.Sleep(1000);
    }
    catch(ThreadAbortException ex)
      {
        if((int)ex.ExceptionState == 0)
        {
          Thread.Abort();
         }
    }
    D.
    try
    {
    Console.Write(x+ “ “);
    Thread.Sleep(1000);
    }
    catch(ThreadAbortException ex)
       {
    if((int)ex.ExceptionState == 0)
       {
        Thread.Rest();
       }
    }
17

A. ThreadStart ts = new
ThreadStart(methodName);

Which of the following syntax is used in instantiating
a ThreadStart?
A. ThreadStart ts = new
ThreadStart(methodName);
B. ThreadStart ts = new Thread(methodName);
C. ThreadStart ts = Thread(methodName);
D. ThreadStart ts = CurrentThread();

18

A. It inherits the Exception class

Which of the following statements is TRUE about
customized exception?
A. It inherits the Exception class
B. It uses a method to set the string message.
C. It cannot be thrown but can be called in the
catch keyword.
D. It contains a child thread for its process.

19

D. throw new FormatException();

Which of the following is the correct format when
manually throwing an exception?
A. throw new FormatException;
B. throw FormatException();
C. throw FormatException{};
D. throw new FormatException();

20

D. Value

What is the output of the following code?
try
{
Console.WriteLine("Value:" + “ “);
}
catch(Exception ex)
{
Console.WriteLine("Null Error"):
}
A. Null Error
B. ArgumentNullException
C. “ “
D. Value

21

B. Thread_myThread = new Thread(new
ThreadStart(Method1));
_myThread.Start();

Which of the following is the correct syntax to begin
a thread?
A. Thread_myThread = new Thread(new
ThreadStart(Method1));
_myThread.Begin();
B. Thread_myThread = new Thread(new
ThreadStart(Method1));
_myThread.Start();
C. Thread_myThread = new Thread(new
ThreadStart(Method1));
_myThread.Initialize();
D. Thread_myThread = new Thread(new
ThreadStart(Method1)):
_myThread.Interrupt();

22

C. Total: 4
      End!

What is the output of the following code?
try
{
  int x = 20; int y = x/ 5;
  Console.WriteLine("Total: " + y);
}
finally
{
Console.WriteLine(" End! ");
}
A. Total: 4
B. End!
C. Total: 4
      End!
D. 20

23

D. None of the above

What is the output of the following code?
int zero = 0;
try
{
int result = 5 / 3;
}
catch(Exception ex)
{
Console.WriteLine("\nException: {0}”,ex.Message);
}
A. Result: 1
B. Exception: DivideByZeroException
C. ExceptionArgumentException
D. None of the above

24

C. Thread.CurrentThread.Name = "Main Thread";

Which of the following is the correct syntax for
setting the name of the current thread?
A. Thread.GetCurrentThread = threadName;
B. Thread.Name = threadName;
C. Thread.CurrentThread.Name = "Main Thread";
D. None of the above.

25

A.
_threadA.Start():
_threadB.Start():
_threadA.Join();
_threadB.Join();

Which of the following is the correct syntax to stop
calling another thread unless the current thread
terminates?
A.
_threadA.Start():
_threadB.Start():
_threadA.Join();
_threadB.Join();
B.
_threadA.Start();
_threadB.Start();
_threadA.Terminat;
_threadB.Terminate();
C.
_threadA.Start();
_threadB.Start():
_threadA.Stop();
_threadB.Stop();
D.
_threadA.Start();
_threadB.Start();
_threadA.Wait();
_threadB.Wait()

26

A. Thread_threadA = new Thread(new
ThreadStart(methodA));
Thread.Sleep(200);

This method is used to pause a thread for the stated
number in milliseconds.
A. ThreadthreadA = new Thread(new ThreadStart(methodA)); Thread.Sleep(200); B. ThreadthreadA = new Thread(new
ThreadStart(methodA));
Thread.Snooze(200);
C. ThreadthreadA = new Thread(new ThreadStart(methodA)); Thread.Pause(200); D. ThreadthreadA = new Thread(new
ThreadStart(methodA));
Thread.Timer(200);

27

D. thread1.Name = "My First Thread";

Which of the following statements assigns a name
to a thread?
A. thread1 ="My First Thread";
B. Name = "My First Thread";
C. thread1.Name("My First Thread");
D. thread1.Name = "My First Thread";

28

B. Total: 15

What is the output of the following code?
public int GetSum(int num1, int num2)
{
   return num1 + num2;
}
public void ValidateSum()
{
  try
  {
    Console.WriteLine("Total: " + GetSum(10,5));
   }
    catch(Exception ex)
   {
    Console.WriteLine("Error");
    }
}

A. Error
B. Total: 15
C. Invalid Input
D. ArithmeticException

29

A. It is an independent execution unit containing a
piece of code.

Which of the following statements is TRUE when
using a Thread class?
A. It is an independent execution unit containing a
piece of code.
B. The first thread in a process to be performed is
known as the parent thread, which is followed
by main thread.
C. It can only be paused and destroyed.
D. It uses a class named ThreadStarted.Name to
run the program.

30

D. All exception types are subclasses in the built-in
class, Exception.

Which of the following statements is TRUE about
exceptions?
A. These are used to create and control threads in
a system.
B. These contain child exception.
C. The finally keyword can transfer control using
break in handling exceptions.
D. All exception types are subclasses in the built-in
class, Exception.

31

C. FormatExceptionX

What is the output of the following code?
try
{
int x,y; y = Convert.Tolnt32("p1"); x= 5/y;
Console.WriteLine("Correct");
}
catch(FormatException ex)
{
Console.Write("FormatException");
}
finally
{
Console.Write("X");
}
A. FormatException
B. CorrectX
C. FormatExceptionX
D. CorrectFormatExceptionX

32

A. class NumberFormatException: Exception
{
public NumberFormatException(){}
}

Which of the following syntax is correct in creating a
custom exception?
A. class NumberFormatException: Exception
{
public NumberFormatException(){}
}
B. class NumberFormatException
{
NumberFormatException(){}
}
C. class Exception
{
public void NumberFormatException(){}
}
D. class Exception: NumberFormatException
{
}

33

C. A sleeping thread returns to the Started state
when the specified sleep duration expires.

Which of the following statements is TRUE about
the life cycle of a thread?
A. The lowest priority Started thread enters the
Stopped state.
B. In life cycle of a thread, the Blocked thread
returns to the Unstarted state after the I/O
operations are complete so it can resume
execution.
C. A sleeping thread returns to the Started state
when the specified sleep duration expires.
D. A new thread begins its life cycle in the Started
state.

34

A. Invalid Format

What is the output of the following code?
try
{
string num = “ “;
int getNumVal = Convert.Tolnt32(num);
Console.WriteLine("Value: " + getNumVal);
}
catch(DivideByZeroException ex)
{
Console.WriteLine("Null Value");
}
catch(FormatException fe)
{
Console.WriteLine("Invalid Format");
}
A. Invalid Format
B. Null Value
C. Value: "“
D. Null Value
    Invalid Format

35

A. Runtime Error

What is the output of the following code?
try
{
throw new StackOverflowException("Ex");
Console.WriteLine("Exception Error");
}
catch(ArithmeticException ex);
{
Console.WriteLine("Exception Caught");
}

A. Runtime Error
B. Exception Error
C. Exception Caught
D. E