C# DOT NET. Q. What is.net framework? Ans:- It is a combination of layers

C# DOT NET Q. What is .net? Ans:-.net is a technology which supports 67 languages like C, C++, C#, Java, VB and etc. Where .net framework is an engine...
4 downloads 0 Views 111KB Size
C# DOT NET Q. What is .net? Ans:-.net is a technology which supports 67 languages like C, C++, C#, Java, VB and etc. Where .net framework is an engine through which we can access and use these languages.

Q. What is the difference between C# and C++? Ans:- C# is a purely object oriented language but C++ is not a purely object oriented language. C++ supports pointer but C# doesn’t support pointers. C++ supports multiple inheritance but C# doesn’t support multiple inheritance.

Q. What is .net framework? Ans:- It is a combination of layers.

Q. What is CLR in C#.net? Ans:-

¾ It is the compiler. ¾ It handles the execution of all .net application. ¾ Our program doesn’t directly communicate with operating system but goes through CLR.

Q. What is CTS in C#.net? Ans:- It is common type system. It is a set of standards, CTS defines the basic datatypes that IL understand. It is easy to map & communicate 2 languages with each other by receiving & passing parameters.

Q. What is jit-er and describe the types? Ans: - It is Just in time compiler. It compiles the IL code to native code for specific O.S. It is different from traditional compilers. Jit-ers can make our code faster when the program is run over an extended period of time. There are 3-types of Jiters:1) Pre-Jit: - Compile the whole code once. 2) Econo-Jit: - Compile the code part by part. 3) Normal-Jit: - Compile only that part of code when called in cache.

Q. What is Garbage Collector in c#.net? Which method is used for garbage collection? Ans:- At the time of running an application, some wanted datas are created known as “Garbages”, which blocks the memory, if that will continue for a long time the application becomes slower having the chance of hang the computer. The .net framework having a feature called “Garbage Collector” which automatically collect the garbages by which the memory will be free & the application become faster. Garbage collector invoked by CLR at regular intervals & removes the dirty objects from memory.

Q. What is assembly in .net? Ans:- Building block of any application is known as “assembly”. It having 3 main parts:1.IL:-Containing business logic 2.Metadata:-Structure of class or data of data. 3.manifest:-Information regarding to assembly.

Q. Can we use not initialized variable? Ans:- Yes, but it is a good programming practice to initialize all variables by using “default constructor”. If we not initialized a variable sometimes it generate an error that “variable not initialized”.

Q. Why is property is used in C#.net? Ans:- To access the private data members.

Q. What is partial class in C#.net? Ans:- A class definition can be spilt into multiple physical files i.e. breaking a big class into small classes. It makes the debugging easier. It is useful in hiding designed-generated code.

Q. What is Boxing and Unboxing? Ans:- Boxing: Converts a value type to reference type & object stored in heap. Unboxing: Converts a reference type to value type & object stored in stack.

Q. What is the top .net class that everything derived from? Ans:- System.Object.

Q. Which keyword is used to call the base class constructor and functions? ANS:-Base keyword.

Q. What is constructor & why private constructor is used? Ans:- 1. Constructors always have the name as the name of the class. 2. Constructor never called explicitly. 3. Constructor never returns any value. 4. A constructor can be a static constructor. Private constructor is used for security purposes.

Q. How many times can a constructor be called during lifetime of the object ? Ans:- Only once.

Q. If we don’t provide a constructor then compiler provides a zeroargument constructor called_____________? Ans:- Default constructor.

Q. Are constructor inherited? Ans:- No, but by using “base” keyword base class constructor can be inherited.

Q. What is inheritance, why we use inheritance and which keyword is used to avoid inheritance? Ans:- The derived class inherits some properties of base class. Use of inheritance: 1. Reuse of existing functionality. 2. Enhance of existing functionality. 3. Change the access level of base class. “Base” keyword is used to avoid inheritance.

Q. Can a new class is created after inheritance? Ans:- No.

Q. In a inheritance chain which members of base class are accessible to the derived class members? Ans:- Protected members & public members.

Q. Are private class variables are inherited? Ans:- Yes, but they are not accessible.

Q. Can you prevent a class from being inherited by another class? Ans:- Yes, by using the “sealed” keyword we can prevent a class from being inherited.

Q. Can we derive a class from a base class even if the base class’s source code is not acaliable? Ans:- yes ,it is possible.

Q. The size of a derived class object is equal to the sum of sizes of data members in the base class & the derived calss? Ans:- True.

Q. What is the difference between structure & class? Ans:-

Structure 1. Keyword: struct 2. Structure can’t be private Or Protected. 3. Structure can’t be define a function. 4. Struct can’t be inherited.

Class 1. Keyword: class 2. Class can be of any type. 3. Can define a function. 4. Can be inherited.

Q. When would a structure variable get destroyed? Ans:- When it goes out of scope.

Q. Can struct inherit class? Ans:- No.

Q. Can struct inherit another struct? Ans:- No.

Q. Can struct implement an interface? Ans:- Yes.

Q. Can structure members declared as protected? Ans:- No.

Q. Can a struct be empty? Ans:- No.

Q. What is abstract class? Ans:- Abstract class can’t be any object. If we write any method under abstract class followed by “abstract method”, then its implementation will be done in the derived class followed by “override” keyword not “new” keyword.

Q. What is interface class? Ans:- Interface can’t create any object. The method within the interface by default is “public/abstract” but we can’t mention it before method name, if mentioned it will generate errors. Interface can inherit other interface. Multiple inheritances are done through multiple interfaces.

Q. Can u specify an accessibility modifier for methods inside the interface? Ans:- No, It will generate an error. Methods in interface are by default public.

Q. What is polymorphism and what are the difference types? Ans:- Polymorphism means “one thing multiple forms”. Ex:- function overloading, method overloading, constructor overloading, function overriding, method overriding, virtual function. There are 2 types of polymorphism:1) Compile-time polymorphism and 2) Run-time polymorphism.

Q. What is function overriding and function overloading? Ans:- Function overriding: It is done in inheritance, if a base class is having a function add() & the derived class is also a function add() having same signature then the derived class function will only execute. To execute the base class function we have to create another object of the base class. Function overloading: Using the same function name with different signature is called function overloading. If is done in polymorphism.

Q. What is Exception and how it is controlled? Ans:- It is a mechanism to handle runtime errors in .net or it can cause the software to terminate the program. Through “exception handling” exceptions are handled. Try() & catch() is used to handle exceptions.

Q. Will finally block executed if an exception has not occurred? Ans:- Yes.

Q. Can multiple catch blocks be executed for a single try statement? Ans:- No, only that proper catch block is executed & then finally statement is executed.

THANK YOU & HAVE A NICE DAY…