.Net Questionnaire

.Net Questionnaire

.Net Questionnaire

.Net questionnaire

1. What is ADO.NET?

Answer 1: ADO stands for Active Data Object and ADO.NET is a set of .NET libraries for ADO.

ADO.NET is a collection of managed libraries used by .NET applications for data source communication using a driver or provider:

ADO.NET provides mainly the following two types of architectures:


2. What are the ADO.NET components?

Answer 2: ADO.NET components categorized in three modes: disconnected, common or shared and the .NET data providers.

The disconnected components build the basic ADO.NET architecture. You can use these components (or classes) with or without data providers. For example, you can use a DataTable object with or without providers and shared or common components are the base classes for data providers. Shared or common components are the base classes for data providers and shared by all data providers. The data provider components are specifically designed to work with different kinds of data sources. For example, ODBC data providers work with ODBC data sources and OleDb data providers work with OLE-DB data sources.

Figure represents the ADO.NET components model and how they work together:

 

3.How can you define the DataSet structure?

Answer 3: A DataSet object falls in disconnected components series. The DataSet consists of a collection of tables, rows, columns and relationships.

DataSet contains a collection of DataTables and the DataTable contains a collection of DataRows, DataRelations, and DataColumns. A DataTable maps to a table in the database. The previous DataSet contains a DataTable that maps to the Orders table because you filled it with a SELECT query executed on the Order table.

 

4.What is Connection Pooling in ADO.NET?

Answer 4: Connection pooling is the ability of reusing your connection to the database. This means if you enable Connection pooling in the connection object, actually you enable the re-use of the connection to more than one user.


5. What is SqlCommand Object?

Answer 5: The SqlCommand carries the SQL statement that needs to be executed on the database. SqlCommand carries the command in the CommandText property and this property will be used when the SqlCommand calls any of its execute methods.


6. What is the DataAdapter Object in ADO.NET?

Answer 6: A Data Adapter represents a set of data commands and a database connection to fill the dataset and update a SQL Server database.

A Data Adapter contains a set of data commands and a database connection to fill the dataset and update a SQL Server database. Data Adapters form the bridge between a data source and a dataset.

7. What are the main components of Entity Framework Architecture?

Answer 7: Entity Framework Architecture consists of the following components:


8. What are the features of the Entity Framework?

Below are some of Entity Framework's basic features:

9. Which are the reserved keywords in C#?

Ans- abstract, char, foreach

 

10. Which method to read a single character from the console?

Ans - read()

11. Comment on the output of this C code?

                 int main()
           {
            int a[5] = {1, 2, 3, 4, 5};
           int i;
           for (i = 0; i < 5; i++)
           if ((char)a[i] == '5')
          printf("%d\n", a[i]);
          else
          printf("FAIL\n");
          }

Ans - Program will compile and print FAIL for 5 times

12.  What is the String in C# meant for?

Ans – Object

13. What will be the output of the following C# code?

  1. static void Main(string[] args)
  2. {
  3.     float a = 16.4f;
  4.     int b = 12;
  5.     float c;
  6.     c =  a * ( b + a) / (a - b) ;
  7.     Console.WriteLine("result is :" +c);
  8.     Console.ReadLine();
  9. }

Ans - 105.8546

14. Choose the statement which defines the Nullable type Correctly:

Ans - a special version of a value type that is represented by a structure, a  nullable type can also store the value null, Nullable types are objects of System.Nullable, where T must be a non nullable value type.

15. Which of the following is the correct way to define and initialize an array of 4 integers?

1.

int[] a = {25, 30, 40, 5};

2.

int[] a;

a = new int[3];

a[0] = 25;

a[1] = 30;

a[2] = 40;

a[3] = 5;

3.

int[] a;

a = new int{25, 30, 40, 5};

4.

int[] a;

a = new int[4]{25, 30, 40, 5};

5.

int[] a;

a = new int[4];

a[0] = 25;

a[1] = 30;

a[2] = 40;

a[3] = 5;

Ans – 1,4,5


16. Which is the correct output of the C#.NET code snippet given below?

int[ , , ] a = new int[ 3, 2, 3 ];

Console.WriteLine(a.Length);

Ans – 18.

17. What will be the output of the following C# code?

static void Main(string[] args)

                {

                    char A = 'K';

                    char B = Convert.ToChar(76);

                    A++;

                    B++;

                    Console.WriteLine(A+ "  " +B);

                    Console.ReadLine();

                }

Ans – L, M

18.What will be the output of the following C# code?

  1. static void Main(string[] args)
  2. {
  3.     int a = 15, b = 10, c = 1;
  4.     if (Convert.ToBoolean(a) && (b > c))
  5.     {
  6.         Console.WriteLine("cquestionbank");
  7.     }
  8.     else
  9.     {
  10.         break;
  11.     }
  12. }


Ans - Compile time error


19. Which is the correct output of the C#.NET code snippet given below?

             int[ , , ] a = new int[ 3, 2, 3 ];Console.WriteLine(a.Length);

Ans  - 18


20. What will be the output of the following C# code?

  1. static void Main(string[] args)
  2. {
  3.     int i;
  4.     int b = 8, a = 32;
  5.     for (i = 0; i <= 10; i++)
  6.     {
  7.         if ((a / b * 2)== 2)
  8.         {
  9.             Console.WriteLine( i + " ");
  10.             continue;
  11.         }
  12.         else if (i != 4)
  13.             Console.Write(i + " ");
  14.         else
  15.             break;
  16.     }
  17.     Console.ReadLine();
  18. }


Ans  - 0 1 2 3

 

21. What will be the output of the following program ?

#include <stdio.h>

void main()

int a=10;

switch(a){

case 5+5:

printf("Hello\n");

default:

printf("OK\n"); }

             Ans -  Hello
                        OK

22.   Which is the best defines static variables members

       Ans - Data which is common to all the objects of a class

23. How many values does a function return?

Ans: 1


24. What does an abstract class contain?

Ans: Abstract methods and Non Abstract Methods


25. In an inheritance chain through which of the following, the base class and its components are accessible to the derived class?

Ans: Class visibility modifiers (public,private etc.)


26. Does a property can be declared inside a class, struct, Interface.

Ans: True


27: The exception classes in C# are mainly directly or indirectly derived from the?

Ans: System.Exception class


28. Which of the following statements are correct about functions?

a)C# allows a function to have arguments with default values

b) Redefining a method parameter in the method’s body causes an exception

c) C# allows function to have arguments with default values

d) Omitting the return type in method definition results into exception

Ans:a

 

29. What are the main components of .NET Framework?

Ans  NET Framework Class Library ï Common Language Runtime ï Dynamic Language Runtimes (DLR) ï Application Domains ï Runtime Host ï Common Type System ï Metadata and Self-Describing Components ï Cross-Language Interoperability ï .NET Framework Security ï Profiling ï Side-by-Side Execution

30. What is an IL?

Ans Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.

31. What is Manifest?

Ans Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things ï Version of assembly. ï Security identity. ï Scope of the assembly. ï Resolve references to resources and classes.


32.What is a data type? How many types of data types are there in .NET ? 

Ans: A data type is a data storage format that can contain a specific type or range of values. Whenever you declare variables, each variable must be assigned a specific data type. Some common data types include integers, floating point, characters, and strings. The following are the two types of data types available in .NET:

ï Value type - Refers to the data type that contains the data. In other words, the exact value or the data is directly stored in this data type. It means that when you assign a value type variable to another variable, then it copies the value rather than copying the reference of that variable. When you create a value type variable, a single space in memory is allocated to store the value (stack memory). Primitive data types, such as int, float, and char are examples of value type variables.

ï Reference type - Refers to a data type that can access data by reference. Reference is a value or an address that accesses a particular data by address, which is stored elsewhere in memory (heap memory).

33. Which statement is used to replace multiple if-else statements in code? 

Ans - In Visual Basic, the Select-Case statement is used to replace multiple If - Else statements and in C#, the switch-case statement is used to replace multiple if-else statements.

34. Differentiate between the while and for loop in C#.?

Ans The while and for loops are used to execute those units of code that need to be repeatedly executed, unless the result of the specified condition evaluates to false. The only difference between the two is in their syntax. The for loop is distinguished by setting an explicit loop variable.