+ All Categories

Oops

Date post: 28-Sep-2015
Category:
Upload: christina-perry
View: 212 times
Download: 0 times
Share this document with a friend
Description:
object oriented pgm
Popular Tags:
28
1.what is the difference between Object based programming and Object oriented programming? -if a language supports only encapsulation then it is called as object based programming language. ex:vb -if a language supports encapsulation, inheritance and polymorphism then it is called as object oriented programming language. ex:c#,java,c++ 2.what are the main concepts of oops? There are four main concepts of oops a)Encapsulation b)Inheritance c)Polymorphism d)Abstraction 3.what is encapsulation and its advantage? -Grouping of related things together is called as encapsulation. -due to encapsulation we can achieve portability. 4.what is Data hiding? -Hiding unnecessary information from user is called as data hiding. - Due to data hiding we can protect behavior of component.
Transcript

1.what is the difference between Object based programming and Object oriented programming? -if a language supports only encapsulation then it is called as object based programming language. ex:vb -if a language supports encapsulation, inheritance and polymorphism then it is called as object oriented programming language. ex:c#,java,c++2.what are the main concepts of oops? There are four main concepts of oops a)Encapsulation b)Inheritance c)Polymorphism d)Abstraction3.what is encapsulation and its advantage? -Grouping of related things together is called as encapsulation. -due to encapsulation we can achieve portability.4.what is Data hiding? -Hiding unnecessary information from user is called as data hiding. - Due to data hiding we can protect behavior of component. - Data hiding can be implemented by using access modifiers.5.what is abstraction? -Hiding complete implementation details from user is called as abstraction. -Due to abstraction we can make user to feel easy and comfortable while using component.6.what is the difference between data hiding and abstraction? -Data Hiding is hiding unnecessary information from user, so that we can protect behavior of component. -Abstraction is hiding of complete implementation details, so that component usage becomes easy.7. what is the difference between encapsulation and class? -Encapsulation is oops concept but class is feature of language by which we can implement encapsulation.8. How to implement encapsulation in C#? -By using class,struct,interface,enum.9.what are the access modifiers ? There are four access modifiers a)private b)protected c)Public d)internal.we can combine protected and internal as protect Interal.10.what is the behavior of protected internal? -protected internal is combination of two access moddifiers. -with in same assembly it will be like a internal, outside assembly it will be like a protected.so that we can 20..0make us of it in any class of same assembly and only derived classes outside assembly.11.what is object? -it is instance of class.12.what is min size of object if there is no member in class? -8bytes13.what is default access modifier for class? -internal14.what is default access modifier for members in class? -private15.what is the base class for all classes in .net? -System.Object.16.what is the difference between class and structure? Class struct -------- --------- -it is reference type -it is value type -all access modifiers allowed -protected not allowed.-all types of methods allowed -Virtual and abstract methods not allowed.-destructor is allowed -destructor not allowed.-all types of constructors allowed -default constructor not allowed.-Inheritance possible -inheritance not posssible-it can implement interface -it also can implement interface.17.is it possible to define method in enum type? -NO 18. How to initialize object? -in two ways we can initialize object. a)by using object initializer. b)By using Constructor.19. What are accessor and mutator methods? -a method which is designed to get value from variables of class is called as accessor method. -a method which is designed to modify values of variables of class is called as mutator method.20. What is the difference between property and indexer? -property is member of class or struct which provides flexible mechanism to read and write from and to the variable of class or struct. -it can be static. -it cannot be overloaded. -Indexer is also member of class or struct which is also providing flexible mechanism to read and write from and to the variable of class or struct by using subscript and index. -indexer cannot be static. -always name of indexer must be this, and it can be overloaded21.is it possible to define property as static? -yes

22.is it possible to define indexer as static? -no23.what is the use of base keyword? -with the help of base keyword we can access base class members from derived class. -always base keyword will refer to immediate base class members. -we can call base class constructor from derived class constructor.24. What is Constructor? -it is special method in the class which is invoked automatically when the class has been instantiated. -it can be used to initialize instance variables of class to some meaningful initial values once object has been created.25.Why name of constructor and class name must be same? -to make the compiler to identify it easily.26.Why return type is not allowed for constructor at programmer level? -constructor should not be used for any other purpose; it must be used for only initialization.27.What are different types of constructors available? -Static constructor -Non static constructor a)default constructor b) Parametric constructor.

28.Explain static constructor? -A constructor can be defined as static member. -static constructor should not have access modifier -it must be parameter less. -it cannot be overloaded. -it can be used to initialize static variables of class but not non static variables. -it is invoked one and only once when the class has been loaded into app domain by class loader.29.when the static constructor is invoked? -it is invoked one and only once when the class has been loaded into app domain by the class loader.30.is it possible to overload static constructor? -No31.what is the need of copy constructor? -it is used to initialize new object with the help of an existing object when new object has been created.32.what is destructor and when is it invoked? -it is also special method which is invoked automatically before object destruction takes place by Garbage collector. -the name of the destructor and the name of the class must be same. -it must be preceded by ~(tilled) character. -access modifiers can't be applied -It must be parameter less33.what is disadvantage of destructor? -the destructor in the class is represented by finalize ( ) -when GC decide to deallocate the memory then it will check is there any finalize method() defined for the object if so then the object will be moved to freechable queue. - finalize() of object is invoked which intern invokes finalize() of system.Object -finalize() of system. Object invokes GC to deallocate memory,so that it will be extra burden to the GC when the destructor has been defined for the class.34.when the class is loaded in to AppDomain? - the class can be loaded into the application domain in the following situations a)when the first object of the class has been created b)when the static method of the class has been invoked.35.How to invoke base class constructor in Derived class constructor? - by using base Keyword.36.what is namespace? -It is a logical container which can contain classes, interfaces, enums, deligates, structures -with the help of the namespace we can avoid name collisions. - A namespace can contain another name space also.37.can we apply access modifier to namespace? -No

38.Is it possible to declare instance variables in namespace? -No39.what is alias name for namespace and when is it required? -While including too many namespaces in the application with the help of using keyword then there is a chance of duplicate members. - too avoid the conflict we can asign a temporary name to the duplicate member which is called as alias name for the namespace.40. what is the difference between namespace and class?

41. what is difference between out and ref parameters? Out Ref-it is write only varibale in side the -it is read and write variable in method. method.-it must be preceded by out keyword -it must be preceded by ref keyword-it need not to be initialized while passing it -it must be initialized while passing to method. to method -Changes are reflected - changes are reflected 42.what is the purpose of params key word? - To pass the array of parameter to the method is called as params Keyword.43. What is binding? - Replacing the method invocation with appropriate base reference is called as binding or linking44. How many types of bindings are available? - There are two types of binding a)Static Binding If the binding process has been carried out during the compilation it is called as Static binding b)Dynamic Binding If the binding process has been carried out at the time of running the application then it is called as dynamic binding45. What is Method overloading? -defining number of methods with same name and different signatures is called as Method Overloading -Method Overloading is possible with in the same class as well as its derived classes. -Any types of methods can be overloaded. -No Keyword must be required for the method.46. what is Method overriding? -Defining number of method with same name, same signature and same return type with different functionality is called as method Overriding. -It is Possible with in the derived classes only -Only virtual and abstract methods only can be Override -override Keyword must be used.47.what is difference between Method overloading and Method overriding?48. what is polymorphism? - Having Different forms to the same method is called as Polymorphism. -With the help of polymorphism we can perform different actions with same method invocation49. what are the types of polymorphism? -There are two types of polymorphism a)static Polymorphism - If the Polymorphism is implemented by using Static binding then it is Static Polymorphism -In C# Static polymorphism can be implemented by using method Overloading and operator Overloading b)Dynamic polymorphism -If polymorphism is implemented by using dynamic binding then it is called as Dynamic Polymorphism -In C# Dynamic polymorphism is implemented by using method Overriding50.what is the difference between abstract class and interface? Abstract Class Interface-----------------------------------------------------------------------------------------------------It is Partially unimplemented class -Fully Unimplemented class-Complete Abstraction is not Possible -Complete Abstraction is possible -All Types of members are allowed -Only methods, Properties indexes are allowed-Object can not be created -Object cant not be created-Access modifier can be applied to the members -Access modifiers can not be applied explictly, public is the default access modifier of the abstract class-Constrctor, destructor are allowed -Constrctor, destructor are not allowed 51.Can we apply private or protected access modifier to interface?-No52.why access modifiers can not be applied to members of interface? - By default members of interface are public and members of the interface must be always exposed.53.why object cannot be created for abstract class or interface? -Abstract classes are Partially unimplemented so that some of the members are not defined -Interface is fully unimplemented so that non of the member will have the implementation -If the object creation is made possible then we need to call the members with out implementation. Thus object creation for abstract class and interface must be avoided54.can we declare member of interface as static? -No55.why multiple inheritance is not possible for classes? -Deriving a new class from two or more bases classes is called multiple inheritances -when the class is derived from too many base classes then there is a chance of duplicate members with full implementation -when that member is invoked w.r.t derived class object then there would be a ambigious situation. -to avoid this ambigious situation multiple inheritance in classes is not allowed in c#.56.what is private implementation for interface member? -while implementing the interface members if there are defined w.r.t interface name then it is called as private implementation -In this implementation members must be private members of the class so that interface members can be invoked w.r.t interface variable name only but not w.r.t object of implemented class. -It is also called as explicit implementation of interface57. what is sealed class? -If a class is declared as sealed class then it cannot be extended i.e inheritance is not possible for that class 58. what is Extension method and how to define it? -If a method is defined to provide extra functionality to existing type with out disturbing its originallity then it is called as extension method. -it is introduced from C# 3.0 -it must be static method -it must be defined with in the static class -it must have the parameter of the type to be extended -parameter must be preceded by this keyword59. Can we Overload destructor?-No60. what is the use of Dispose()? -It is used to invoke the GC dynamically.61.what is the difference between String and String Builder classes? - Both are used to manipulate and maintain the string -each method of the string will return another string object -each method of string builder will manipulate with in the same object with out returning another string object62.what is the advantage of var keyword? - it is introduced from C# 3.0 -It is used to declare the local variables -var type of variable must be intialized during the declaration itself. -Type of variable will be decided based on its intialization -It can not be intialized with null, but it can contain the reference of object -var type of variable can not be passed as a parameter to the method.63.Can we assign null to var type of variable? --No

64.Can u allow class to be inherited,but method must be prevented from being overridden?65.what is the difference between abstract method and virtual method?abstract method virtual method------------------------------------------------------------------------------Abstract Keyword must be used -virtual keyword must be used-It should not have defination in the base class -It must have the defination in the base class-It must be overridden in the derived classes -It may or may not be in the derived classes-It must be with in the abstract class -It can be with in the abstract and non abstract classes66.Can we define virtual method as private member? -No67.can we define abstract method as private member? -No68.Can we define abstract method as static?-No69.Can we declare private class in namespace?-No, members of the namespace must be either internal or public70.what is the difference between new and override keywords? - New is used to create the object dynamically -Override key word is used to override either virtual or abstract methods71.Can we Create object without defining class? -Yes, we can create an object by using new operator with some intialization. -Based on intialization approriate annonomous type will be defined by the compiler.72.what is the purpose of this? -it is a predefined reference variable which contain the reference of a current object or active object. - when the names of the parameters and instance variable names are same then instance variables can be differentiated from the parameters by using this keyword. -This can be used with instance methods only.73.what is the difference between Array and ArrayList? Array ArrayList---------------------------------------------------------------------------------------------- -it is typed collection -it is untyped collection-fixed size -size will be increased dynamically.-boxing and unboxing not needed -extra burden of boxing and unboxing.74.What is difference between List and ArrayList?e List ArrayList---------------------------------------------------------------------------------it is generic collection -it is non genaric collection-boxing and unboxing is not needed -Extra burden of boxing and unboxing-size will be inbcreased dynamically -size will be increased dynamically75.what is the diffference between Hashtable and SortedList?-both the collections are defined as Dictionaries where in elements are stored in the form of (key,value) pair,but in sortedList values are maintained according to keys in ascending order.76.what is assembly? -it is language independent,self described portable software component.77.Is IL language is OO? -no78.what are different types of assemblies? -there are three types of assemblies a)private assembly --------------------- -an assembly with out strong name key is called as private assembly -when private assembly is used in application,then copy of it will be available as part of application.so that memory will be wasted when too many application are running at a time. -if some changes are made in assembly then they are not reflected to application until its compilation.

b)public or shared assembly -------------------------------- -an assembly with strong name key and placed in GAC is called as shared assembly or public assembly. -Advantages: --------------- -no memory wastage if even too many application using same assembly are running. -if some changes are made to assebly then those changes are automatically reflected to application with out recompilation c)satilite asembly ------------------- -it is private or public assembly with resource file. -it is used while creating assembly for multi linguistic purpose.79.What is digital signature of an assembly? -it is combination of private key and hash algorithem value of aseembly. -digital signature of an assembly will be checked while installing it into GAC.80.what is PE file? -an assembly with win32 header is called as PE file -it is microprocessor independent.81.what is ilasm.exe? -it is a tool which is used to convert assembly into PE file.82.What is ILDASM.exe? -it is also a tool which is used to see the content of assemby in text format.83.What are advantages of genarics? -Boxing and unboxing burden can be reduced while working with collections. - Code burden on developer can be reduced.

84.What is boxing and unboxing? -Converting value type into reference type is called as boxing. -During boxing type casting will be done implicitly -Converting reference type to value type is called as unboxing -during unboxing type casting must be done explicitly 85.What are the disadvantages of boxing and unboxing? -During boxing and unboxing values must be copied from method stack to managed heap and viceversa. -During unboxing if typecasting is not done properly then it will raise exception called InvalistCastException.86.what is delegate? -it is reference type which represents method. -delegate object can contain reference of method -with the help of delegate object we can invoke a method dynamically based on its reference.87.what are different types of delegates? there are two types of delegates: a)single cast delegate: -if delegate object contains only one method reference then it is called as single cast delegate..

b)multi cast delegate: -if delegate object contains more than one method reference then it is called as multicast delegate. -with the help of multicast delegate we can invoke multiple methods sequentially with single call.88. what is lambda expression? -representing complete method definition with the help of simple expression is called as lambda expression89. What are different types of lambda expressions? -there are two types of lambda expressions a)predicate: A lambda expression which is designed to return either true or false is called predicate b)projection: A lambda expression which is designed to return other than true or false is called projection.90. What is Annynomous method? A method which is assumed by the compiler based on the definition of the delegate and definition of the method given by developer is called as anonymous method.91.what is Dll hell problem? -in windows environment all application dlls are copied to system32 folder of windows directory,so that there is a chance of overwriting one application dll by another application dll. -if share dlls are used by multiple applications then due to uninstallation of one application another application may be effected which is called as dll hell problem.92.explain different parts of assembly version? Assembly version contains four parts a)major:this part indicates the new namespace,class ,interface ,delegate insertion into assembly b)minor:this part indicates the new methods ,properties ,,,insertion into assembly c)Build:this part indicates number of times bugs fixed in assembly d)revision:this part indicates how many times assembly has been rebuilt irrespective of bugs reported or not93.What is the purpose of checked and unchecked blocks? -checked block is used to provide a piece of code where there is a chance of raising OverFlowException. -Unchecked block doesnt raise OverFlowException.94.What is typeof()? -it is operator which is used to extract complete type information dynamically. -it will return System.Type object.95. What is Anonymous Type? - A type which is assumed by compiler based on initialization of an Object is called as Anonymous Type.96.Does C# Supports variable number of arguments? -Yes. C# Supports variable number of arguments by using parms keyword97.What is diff b/n Constant,Static and Read Only? -Constant and Read-only keyword are used to make a field constant which value cannot be modified. Static keyword is used to make members static that can be shared by all the class objects. In this article, I am going to explain the difference among these three.- A read only field can be initialized either at the time of declaration or with in the constructor of same class. Read only keyword can be apply to value type and reference type (which initialized by using the new keyword) both.1. Ex: class MyClass2. {3. readonly int X = 10; // initialized at the time of declaration4. readonly int X1;5. public MyClass(int x1)6. {7. X1 = x1; // initialized at run time8. }}98)Once Try block is invoked, without using catch and finalize method how will we come out of the exception?- By Using System. Exit(0).


Recommended