Untitled Deck Flashcards
(30 cards)
What is the output of the following code?
```C#
try
{
int x = 20;
int y = x / 5;
Console.WriteLine(“Total: “ + y);
}
finally
{
Console.WriteLine(“ End! “);
}
~~~
Total: 4 End!
This exception is thrown when an unacceptable argument is passed to a method.
ArgumentNullException
This is used to get the size of the stream.
long length
Which of the following statements is true about interface?
An interface can be implemented by multiple classes in the same program.
Assuming the method implementations are correct, what will be displayed by the program below?
```C#
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));
}
~~~</int></int></string></string></Val>
Paul Cruz 230
What will be the output of the following program when compiled and executed?
```C#
using System;
public class Number
{
public Number(int number)
{
Console.WriteLine(number);
}
}
public class LocalNumber : Number
{
public LocalNumber(int num1, int num2) : base(num2)
{
Console.WriteLine(num1);
}
public static void Main(string[] args)
{
LocalNumber In1 = new LocalNumber(25, 50);
Console.ReadKey();
}
}
~~~
25 50
Which has a correct syntax of declaring a namespace?
namespace ExampleNamespace;
Which of the following types of stream refers to the objects where the data is written?
Output stream
Which of the following lines of code retrieves a value even if the current stream supports reading or not?
public abstract bool CanRead { get; }
Which of the following codes retrieves the value that the current stream supports reading?
public override bool CanRead { get; }
What property of a stream supports position request and returns true?
bool CanSeek
Which of the following statements is true about the System.Data.Sql
namespace?
It contains new generic interface and classes for SQL Server data access.
What is the output of the following statements when executed?
```C#
StringBuilder word = new StringBuilder(“welcome”);
word[2] = ‘ ‘;
Console.Write(word);
~~~
we come
These primitive types directly store the value to the memory address.
Value types
This syntax can be used to retrieve the value that will determine the current stream timeout.
public virtual bool CanTimeout { get; }
Which of the following has an invalid conversion of data type?
int x = 3; short y = x;
Which of the following syntax is correct in creating a custom exception?
class NumberFormatException : Exception { public NumberFormatException() { } }
These special accessors are used to access private data fields of a class and still promote encapsulation.
Properties
Which has a correct syntax of importing a namespace?
using ExampleNamespace;
Which of the following syntaxes is used for stored procedure calls?
SqlCommand cmd = new SqlCommand(myQuery, sqlConnection);
What is the output of the following program when compiled and executed?
```C#
using System;
public abstract class Number
{
public abstract void updateNumber(int n);
}
public class LocalNumber : Number
{
public void updateNumber(int n)
{
Console.WriteLine(n);
n = n++;
}
}
public static void Main(string[] args)
{
LocalNumber In1 = new LocalNumber();
In1.updateNumber(51);
}
~~~
51
This code specifies the name of the file to be opened.
StreamWriter(string fileName)
This statement is used to skip the remaining below statements of a loop and jumps back to evaluate the condition.
continue statement
This keyword is used to call the exception manually.
throw