0

Visual C# Programming

Attempted 0/25 Correct 0 Score 0

How can we prevent a class from being inherited?

  1. Declare the class as final.

  2. Declare the class as shadows.

  3. Declare the class as sealed.

  4. Declare the class as overrides.

  5. Declare the class as abstract.


Correct Option: C
Explanation:

Classes declared with sealed keyword cannot be used as base class for other classes. They must be instantiated to be used.

Which of the following is NOT a valid assignment operator in C#?

  1. =

  2. +=

  3. *=

  4. %=

  5. /=


Correct Option: A
Explanation:

= is not a valid operator in C#. The correct sign for division is the forward slash (/).

Which of the following members of base class are accessible to the derived class members during inheritance?

  1. Private and Public

  2. Protected and Public

  3. Private and Protected

  4. Static and Public

  5. Static and Protected


Correct Option: B
Explanation:

The protected and public members of a base class can be accessed from the derived class.

Which of the following is the root of the .NET type hierarchy?

  1. System.Object

  2. System.Type

  3. System.Console

  4. System.Enum

  5. System.Environment


Correct Option: A
Explanation:

This is the ultimate base class of all classes in the .NET Framework. It is the root of the type hierarchy.

Which of the following is NOT a valid .NET Exception class?

  1. IndexOutOfRangeException

  2. OverflowException

  3. ArrayMemoryException

  4. ArrayTypeMismatchException

  5. Exception


Correct Option: C
Explanation:

There is no such exception as 'ArrayMemoryException' in C#.

Which of the following functions is used to remove a particular item from a ListBox?

  1. DeleteAt()

  2. RemoveFrom()

  3. DeleteIndex()

  4. RemoveAt()

  5. DeleteFrom()


Correct Option: D
Explanation:

To remove an item from a particular index, the correct function is 'RemoveAt(int index)'. 

Which of the following statements is true?

  1. The Array values are always sorted.

  2. The default value of numeric array elements is zero.

  3. Array elements can be of integer type only.

  4. The rank of an Array is the total number of elements it can contain.

  5. An array can be resized during the runtime.


Correct Option: B
Explanation:

Since the default value of an int is 0, the default value of all the elements in a numeric array is 0.

Which of the following is the correct syntax of displaying a 'Message Box' in C#?

  1. msgbox.show()

  2. MessageBox.Show()

  3. Msgbox()

  4. msgBox.show()

  5. MessageBoxShow()


Correct Option: B
Explanation:

A message box is used to displays the specified text in a small window containing one or more buttons.

Which of the following is NOT a valid C# keyword?

  1. lock

  2. volatile

  3. out

  4. namespace

  5. form


Correct Option: E
Explanation:

Form is not a keyword in C#. It represents a visual window or frame that can be used to place user interface controls like buttons, labels or listbox.

Which of the following is FALSE regarding interfaces in C#?

  1. A class can inherit a base class and can also implement one or more interfaces.

  2. An interface cannot contain the definition of a method.

  3. An interface can inherit from one or more base interfaces.

  4. An interface cannot contain an event.

  5. Interface members are by default public.


Correct Option: D
Explanation:

Interfaces can contain methods, properties, events, indexers or any combination of those four member types.

Which of the following statements is incorrect about delegate?

  1. Delegates are type-safe.

  2. Delegates are reference types.

  3. Delegates serve the same purpose as function pointers in C and pointers to member function operators in C++.

  4. Only one method can be called using a delegate.

  5. A delegate does not know about the class of the object that it references.


Correct Option: D
Explanation:

A delegate can call more than one methods. A delegate that can have more than one element in its invocation list is known as MultiCast Delegate.

Which of the following is INCORRECT regarding static constructors?

  1. There can be only one static constructor in the class.

  2. The static constructor can be parameterised.

  3. It can only access the static members of the class.

  4. There should be no access modifier in static constructor definition.

  5. The static keyword is used to declare a static constructor.


Correct Option: B
Explanation:

The static constructor should be without parameters. If a static constructor is declared parameterised, the compiler will display an error.

Which property or method is used to assign a name to a Thread?

  1. setName()

  2. isName()

  3. Name

  4. Start()

  5. getName()


Correct Option: C
Explanation:

Each thread has a Name property that we can set for the benefit of debugging. We can set the name of a thread only once. Naming a thread has its advantages while debugging an application.

Which of the following statements is INCORRECT with reference to StringBuilder class?

  1. StringBuilder represents a mutable string of characters.

  2. StringBuilder should be used when we want to make a significant number of changes to a string.

  3. If characters are added to the StringBuilder object, its length increases at runtime.

  4. We should always use StringBuilder in place of String.

  5. We can remove characters from a StringBuilder at runtime.


Correct Option: D
Explanation:

Although the StringBuilder class generally offers better performance than the String class, we should not always replace String with StringBuilder. It depends on whether we want to edit the string during the runtime or not.

Which of the following is NOT a benefit of the CLR?

  1. Garbage collection

  2. Structured exception handling

  3. Allows creation of multithreaded, scalable applications

  4. Use of delegates instead of function pointers for increased type safety and security

  5. Support for ADO.NET


Correct Option: E
Explanation:

ADO.NET is an object-oriented set of libraries that allows you to interact with data sources. It cannot be said as an advantage of CLR.

What does the parameter Initial Catalog denote inside a Connection String?

  1. Database name

  2. Username

  3. Driver Name

  4. Name of RDBMS Application

  5. Project Name


Correct Option: A
Explanation:

The initial catalog parameter denotes the name of the database to which we want to connect. For example, in the connection string given below, Sample is the name of the database. Data Source=servername;Intial Catalog=Sample;Integrated Security=true

What will be the output of the above code?

String str1 = Lets learn programming in C#;
String str2;
str2 = str1.Substring(5,10);
Console.WriteLine(str2);

  1. Error

  2. learn pro

  3. earn progr

  4. earn prog

  5. learn prog


Correct Option: E
Explanation:

learn prog is the correct answer because the extraction will begin from the 5th character, which is 'l' and will extract 10 characters from there. The 10th character from 'l' is 'g'.

Which of the above collections provide(s) an index based input/output?

1. Stack 2. Queue 3. BitArray 4. ArrayList 5. HashTable

  1. 1 and 2 only

  2. 3 and 4 only

  3. 5 only

  4. 1, 2 and 5 only

  5. All of the above


Correct Option: B
Explanation:

The BitArray class stores a compact array of bit values. These value are boolean in nature storing 0 and 1. Elements in an BitArray are accessed using an integer index which starts from 0. Arraylist represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. However, unlike array, you can add and remove items from a list at a specified position using an index.

What will be the output of the above code?

for(;;)
Console.Writeline(Hello);

 

  1. Compilation Error

  2. Hello will be printed only once.

  3. Hello will not be printed even once.

  4. Hello will be printed infinite number of times.

  5. Runtime error


Correct Option: D
Explanation:

Since the for loop has no initialisation and condition, the loop will run infinitely. The message 'Hello' will be printed infinite number of times.

What can be defined as 'emphasis on the idea, qualities and properties rather than the particulars'?

  1. Generalisation

  2. Abstraction

  3. Encapsulation

  4. Object

  5. Class


Correct Option: B
Explanation:

Abstraction is an emphasis on the idea, qualities and properties rather than the particulars. It places the emphasis on what an object is or does rather than how it is represented or how it works. Thus, it is the primary means of managing complexity in large programs.

Which of the following should be used to implement a 'Like a' or a 'Kind of' relationship between two entities?

  1. Polymorphism

  2. Templates

  3. Inheritance

  4. Containership

  5. Encapsulation


Correct Option: C
Explanation:

When a class derives it functionality (methods and properties) from another class, it is known as inheritance. The derived class can access all the non-private data and behaviour of the base class.

Which of the following is a 64-bit Integer?

  1. char

  2. long

  3. short

  4. int

  5. byte


Correct Option: B
Explanation:

A long type is a 64-bit signed integer type. It has a large range covering from -923,372,036,854,775,808 to 9,223,372,036,854,775,807.

Which of the following statements is INCORRECT with reference to functions?

  1. Function definitions can be nested.

  2. A function can only return one value at a time.

  3. To return the control from middle of a function, the return clause should be used.

  4. Function calls can be nested.

  5. Functions can be called recursively.


Correct Option: A
Explanation:

We can call a function from within another function but we cannot define a function inside another. The functions must be defined independent of each other.

Which of the following can be described as a collection of data retrieved from a data source?

  1. Dataset

  2. SQLDataReader

  3. SQLDataAdapter

  4. SQLCommand

  5. SQLTransaction


Correct Option: A
Explanation:

A Dataset represent an in-memory collection of data retrieved from a data source. It can contain records of multiple tables. A Dataset can be used for adding and manipulating records of a table in a disconnected dataset.

What is the default value of a 'boolean' variable?

  1. 0

  2. 1

  3. True

  4. -1

  5. False


Correct Option: E
Explanation:

A boolean type can store either true or false. The default value of boolean is false.

- Hide questions