.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:
- Enterprise applications handle a large amount of data. This data is primarily stored in relational databases, such as Oracle, SQL Server, and Access and so on. These databases use Structured Query Language (SQL) for retrieval of data.
- To access enterprise data from a .NET application, an interface was needed. This interface acts as a bridge between an RDBMS system and a .NET application. ADO.NET is such an interface that is created to connect .NET applications to RDBMS systems.
- In the .NET framework, Microsoft introduced a new version of Active X Data Objects (ADO) called ADO.NET. Any .NET application, either Windows based or web based, can interact with the database using a rich set of classes of the ADO.NET library. Data can be accessed from any database using connected or disconnected architecture.
ADO.NET provides mainly the following two types of architectures:
- Connected Architecture.
- Disconnected Architecture.
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.
- The Command Object uses the connection object to execute SQL queries.
- The queries can be in the form of Inline text, Stored Procedures or direct Table access.
- An important feature of Command object is that it can be used to execute queries and Stored Procedures with Parameters.
- If a select query is issued, the result set it returns is usually stored in either a DataSet or a DataReader object.
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:
- Entity Data Model (EDM): EDMs abstract logical or relational schema and expose conceptual schema of data with a three-layered model, i.e., Conceptual (C-Space), Mapping (C-S Space), and Storage (S - Space).
- LINQ to Entities (L2E): L2E is basically a query language generally used to write queries against the object model. The entities defined in the conceptual model are returned by L2E.
- Entity SQL (E-SQL): Similar to L2E, E-SQL is another query language (for EF6 only). The developer must however learn it separately since it is more difficult than L2E. Internally, E-SQL queries are translated or converted to data store-dependent SQL queries. EF is used for converting E-SQL queries to their respective datastore queries, such as T-SQL.
- Entity Client Data Provider: This layer's main task is to convert E-SQL or L2E queries into SQL queries that the database understands. In turn, the ADO.Net data provider sends and retrieves data from the database.
- Net Data Provider: It uses standard ADO.NET to enable interaction with the database.
- Object Service: It is a service that facilitates access to a database, and returns data for analysis when necessary. By using it, you are able to translate data coming from entity clients into entity object structures.
8. What are the features of the Entity Framework?
Below are some of Entity Framework's basic features:
- Cross-Platform: It is lightweight, extensible, open-source, and can be used on Windows, Linux, and Mac.
- Querying: It allows us to retrieve data from underlying databases using LINQ queries, which are then transformed into database-specific query languages.
- Modeling: EDMs (Entity Data Models) are typically created based on POCOs (Plain Old CLR Objects), which are entities with get/set properties of different types. This model is used when querying and saving entity data to the underlying database.
- Change Tracking: By using the SaveChanges method of the context, EF tracks changes to entities and their relationships and ensures the correct updates are performed on the database. Change tracking is enabled by default in EF but can be disabled by setting the AutoDetectChangesEnabled property of DbContext to false.
- Saving: Upon calling the "SaveChanges()" method, EF executes the INSERT, UPDATE, and DELETE commands to the database based on the changes made to entities. "SaveChangesAsync()" is another asynchronous method provided by EF.
- Concurrency: EF provides built-in support for Optimistic Concurrency to prevent an unknown user from overwriting data from the database.
- Transaction: EF's transaction management capabilities automate the querying and saving of data. Furthermore, you can customize the way that transactions are managed.
- Caching: First-level caching of entities is supported out of the box in the EF. Repeated queries will retrieve data from the cache rather than the database in this case.
- Built-in Conventions: EF conforms to the conventions of configuration programming and has a set of default settings that automatically configure the model.
- Configuration: By using the data annotation attribute or Fluent API, we can configure the EF model and override the default conventions.
- Migrations: EF provides migration commands that are executable on the command-line interface or NuGet Package Manager Console to incrementally update the database schema to keep it in sync with the application's data model.
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?
- static void Main(string[] args)
- {
- float a = 16.4f;
- int b = 12;
- float c;
- c = a * ( b + a) / (a - b) ;
- Console.WriteLine("result is :" +c);
- Console.ReadLine();
- }
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?
- static void Main(string[] args)
- {
- int a = 15, b = 10, c = 1;
- if (Convert.ToBoolean(a) && (b > c))
- {
- Console.WriteLine("cquestionbank");
- }
- else
- {
- break;
- }
- }
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?
- static void Main(string[] args)
- {
- int i;
- int b = 8, a = 32;
- for (i = 0; i <= 10; i++)
- {
- if ((a / b * 2)== 2)
- {
- Console.WriteLine( i + " ");
- continue;
- }
- else if (i != 4)
- Console.Write(i + " ");
- else
- break;
- }
- Console.ReadLine();
- }
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.