latest Post

497 C# Single line interview Questions Part - 3

 300) What are the three layers used in application development? i) Presentation logic is written in Presentation Layer. ii) Business logic is written in Business Access Layer. iii) Database logic is written in Data Access Layer.

 301) What is a delegate? Delegate is a function pointer. It is used to store function address. These are designed by using pointers, so delegates are unsafe.

302) Is delegates takes arguments and return types? Yes. Delegate can take arguments and return types also.

303) What are the types of Delegates? i) Single cast delegate ii) Multi cast delegate

 304) How can you declare a delegate? Based on function prototype you have to declare the delegate.

 305) What is single cast delegate? Single cast delegate refers only one function address.

306) What is multi cast delegate? Multi cast delegate refers “multiple single cast delegates” using multicast delegate, we can access multiple features from the class.

307) Write the syntax of the declaring the delegate? <Access specifier> Delegate <type> <delegate name> ( arguments list);
 308) What is a user control? User control is nothing but user defined control.

 309) What is the advantage of the user defined control? It avoids the repetition of design and code.

310) How can you create your own user controls? You can create your own user controls using “WindowsFormControlLibrary” template.

311) Can a user control run individually? No. the user control can’t run individually.

312) Which class can inherit by user control? User control inherits the class called “System.Windows.Forms.UserControl”

 313) How to add a user control to the tool box? To add the user control to the tool box follows the steps.

Go to “Tool Box” right click on “General” tabselect “Add tab”, enter name for the controlright click on itselect “choose items”click on “Browse”select the required .DLL fileclick on “ok”. 

314) Using which keyword Anonymous types is declared? Anonymous types are declared using “var” keyword

 315) In which framework, anonymous types are introduced? Anonymous types are introduced in the framework version 2.0

 316) Is it possible to use the anonymous types as global variables? No. you can’t be use the anonymous types as global variables.

317) What is a lambda expression?  Lambda expression is a function without any name and calculates and returns a single value.

318) What is the use of lambda expressions? Lambda expressions are used to work on some group of data. In general lambda expressions used in aggregate functions.

319) How can you represent the lambda expression? Lambda expression is represented by “=>” (goes to).

 320) What are the types of lambda expressions? Lambda expressions are divided into 2 categories i) Expression lambda. ii) Statement lambda.

 321) Write the syntax of the expression lambda? inputParameters  =>  Expression;

 322) Write the syntax of the statement lambda? inputParameters  => {Expression};

323) What is an anonymous method? Anonymous method is an inline function. It is defined within the delegate.

 324) What is the use of anonymous method? Anonymous method is used to reduce code in delegates.

 325) What are the generic delegates? We have three types of generic delegates. They are i) Func< > ii) Action< > iii) Predicate< >

326) What is a Func< > delegate? Func< > is a readymade delegate. We can define inputs and outputs different data. Eg: Func<double, double> obj=x => 3.14*x*x; 

 327) What is the Action< > delegate? Action< > is a readymade delegate. It takes only input values and return types always “void”. Eg: Action<string> obj=x=>MessageBox.Show(x);

328) What is Predicate< > delegate? Predicate< > is a readymade delegate. It is used for checking purpose. It returns always Boolean values i.e. either true or false. Eg: Predicate<string> obj= x => x.length>5;

 329) What is the use of generic delegates and lambda expressions? Using generic delegates and lambda expressions we can write the delegate code simpler and shorter.

 330) What is LINQ? LINQ stands for Language Integrated Query. This is a query writing technology. This is most useful while working with large amount of data in the live projects.

331) In which framework LINQ is introduced? LINQ concept is introduced in .NET framework 3.5

332) What is the use of LINQ? You can write the queries using LINQ on database data and non database data like arrays, objects and XML. LINQ is known as Object Relation mapping tool for .NET.

333) Which namespace is to be import when you use LINQ? “System.Linq” is the namespace.

 334) Write the syntax of the LINQ? From… in… let…where…orderby…select…groupby…

 335) What are the mandatory clauses of LINQ? When you write a LINQ query you must use three 
clauses. They are i) From clause ii) In clause iii) Select clause 336) What is the use of “from” clause? From clause is used to specify the iteration variable name. This acts as a alias name for the data source.

 337) What is the use of “In” clause? In clause is used to specify the main data source for the query.

 338) What is the use of “let” clause? This is used to declare a new identifier with a value that is to be used during the query execution. This is optional clause.

339) What is the use of “where” clause? This is used to specify the condition in the query. This is most frequently used optional clause.

340) What is the use of order by clause? This is used to specify the sorting expression if required. This is optional clause.

341) What is the selection clause? This is used to specify the object, which is required in the query results.

 342) What is the group by clause? This is similar to “group by” clause in SQL. This retrieves grouped data, based on a column. This is optional clause. 343) How to work with LINQ Queries? To work with LINQ queries, you must follow the steps i) Prepare the data source. ii) Writing the query. iii) Executing the query.

344) Write the general syntax of LINQ?  var x= from n in <collection>  Select  n;

 345) Which template is used for working with LINQ to SQL? “LINQ to SQL Classes” template is used for working with LINQ to SQL.

 346) What is the extension of the “LINQ to SQL classes”? “.dbml” is the extension of the “LINQ to SQL classes”. “dbml” stands for Database Markup Language.

347) Which methods are used when you insert a record into table using LINQ? InsertOnSubmit( ) and SubmitChanges( ) methods are used when you insert a record into the table using LINQ. 

348) Which method is used when you delete a record from the table using LINQ? DeleteOnSubmit( ) and SubmitChanges( ) methods are used when you delete a record from the table using LINQ.

 349) What is the class name when you add a LINQ to SQL classes template with name as “Sample.dbml” in your project? A class is created with the name “SampleDataContext”.

 350) What happens when you drag and drop a table into the object relation designer form of LINQ to SQL classes? The table is treated as a class and the column names are treated as properties.

351) What happens when you drag and drop a stored procedure into the right pan of LINQ to SQL classes? The stored procedure is treated as a method.

352) What is the distributed technology?

A distributed technology is a technology that allows you to connect Business access layer to presentation layer.

353) Write some well known distributed technologies? The following are the well known and important distributed technologies. i) DCOM( Distributed Component Object Model) ii) Remoting iii) Web services iv) WCF(Windows Communication Foundation)

 354) Write about DCOM? DCOM is used before .NET. It is platform dependent.

355) Write about Remoting? i) It is introduced in .net frame work. ii) It is platform independent. iii) It
 is suitable for the windows applications that run on LAN or intranet. iv) It supports TCP and HTTP protocols.

 356) Write about web services? i) It is available in ASP.NET ii) It is platform independent. iii) It is supported for web only. iv) It is language independent. v) It supports SOAP and HTTP protocols.

 357) Write about the WCF? i) It is introduced in .NET 3.0 ii) It is platform independent. iii) It is language independent. iv) It supports for any type of network. v) It is supported in any type of applications.

358) What are Extender controls? The extender controls are  i) Tool Tip ii) Error Provider iii) Help Provider

359) What is the use of Tool Tip control? Tool Tip is used to display the tool tips as part of our application.

 360) Write the some important properties of tool tip? Following are some important properties of tool tip. i) Tool Tip Icon , Eg: tool tip icon = info/warning/error ii) Tool Tip Title, Eg: tool tip title = alert iii) isBalloon, Eg: isBalloon = true

 361) What is the use of error provider? Error Provider control is used for showing error icons.

362) Which method of error provider is used for showing the error icons? SetError( ) is the method of Error Provider is used to display icons. It takes two parameters. First parameter takes the control object and second parameter takes the error message.

 363) What is the use of Help Provider? The Help Provider is used display the help files at runtime.

364) What is the use of timer control? Timer is a control it executes code at regular interval of time. The main advantage of the timer control is it runs a separate process.

365) What are the important properties of timer? i) Enabled ii) interval

366) What is the default event of timer control? The default event of the timer control is “tick”.

367) Write a statement for display the current system time using timer control? Label1.text =DateTime.Now.TolongTimeString();

368) What are the different types of dialog boxes? i) Open File Dialog. ii) Font Dialog. iii) Color Dialog. iv) Save File Dialog.

369) Which method is used display the dialog box at runtime? ShowDialog( )  is method is used for display the dialog boxes at runtime.

370) What are the menus and tool bar controls? i) Menu Strip ii) Tool Strip iii) Status Strip iv) Context Menu Strip

 371) What is the use of web browser control? Using web browser control you can design your own web browser.

 372) Write the steps to add a control at run time?

i) Create a control object  Eg: <controlClassName> obj = new <controlClassName>( ); ii) Assign the properties ( like name, text etc.) Eg: obj . <propertyName> = value; iii) Add the controls to the container. Eg: <containerName>.Controls.Add(obj);

373) What are the types of windows applications? The windows applications are two types. i) SDI applications (SDI – Single Document Interface) ii) MDI applications(MDI – Multi Document Interface)

374) What is an SDI application? An SDI application can contain multiple forms. Each form will be executed as an individual form.

 375) What is a MDI application? A MDI application can contain multiple forms in which one form acts as parent form and remaining forms as child forms.

 376) What is an active child form? Among all child forms only one form is in active state while other forms are in inactive state. That form is known as Active child form.

 377) Is the parent form contains any UI design? No. parent form does not contain any UI design.

 378) Is it possible to move any child form, outside of the parent form? Not possible.

 379) Write the implementation of MDI applications? i) Convert the form as parent form Eg: to convert, set that form’s property “ISMDIContainer=true”. ii) Invoke the child form at runtime from the parent form <childFormName> obj=new <childFormName>( ); Obj.MDIParent=this; Obj.Show( );

 380) What is the use of track bar control? The track bar control is used to provide the visualizations for the value selection.

381) What are the important properties of the track bar control? i) Value   ii) minimum  iii) maximum   iv) Tick frequency  v) orientation  vi) Tick Style

382) What is a tab control?  
Tab control is a collection of tab pages. Every tab page is a container. Container means collection of controls.

383) What is exception handling? The process of handling the runtime exceptions is called as Exception handling.

384) What is an Exception? Exception means a runtime error.

 385) What are the types of errors? Errors are two types. They are i) Compile time errors. ii) Runtime errors.

386) What are compile time errors? Errors occurred at the time of compiling the program is known as compile time errors.

 387) What are runtime errors? Errors occurred during the execution of the program are known as runtime errors.

388) What are the types of application termination? There are two types of application terminations. They are i) Normal Application Termination. ii) Abnormal Application Termination.

389) What is Normal Application Termination? Whenever the program execution control executes all the statements in the program and reaches to end of the code. The application will be terminated automatically. It can be called as Normal application termination.

 390) What is Abnormal Application Termination? Whenever an exception occurred at run time, the application will be terminated automatically. It can be called as abnormal application termination. 

391) What is the syntax for exception handling? Try { -- } Catch (Exception ex) { -- } -- -- Finally

{ -- }
 392) Which block is executed first, try block or catch block? The system tries to execute try block first, if it contains any run time errors then only its corresponding catch block will be fired.

 393) What is an exception object? Whenever a run time error occurred in the try block, then try block throws the exception to the catch block in the form of an object. That object is called “Exception Object”.

 394) What is an error handler? Catch block is known as error handler.

 395) Where you can write the catch block? Catch block is immediately follows a try block.

 396) Is it possible write more than one catch block for single try block? Yes. We can write more than one catch block for single try block.

 397) Can you write a try block without a catch block? No. you can’t write a try block without a catch block.

398) Which type of code you write within the catch block? You need to write the code within catch block which display error information to the user.

399) How many parameters are required for catch block? Catch block requires one parameter which is an exception object thrown by try block.

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment