Oops concepts in c# net interview questions and answers pdf




















OOPS works on the objects. This post is for programmers gearing for their first C OOPs interview. C is the most popular object-oriented programming language used by millions of developers. So every interviewer rates your C programming skills based on how well-versed you are in OOPs concepts.

Hence, we picked 25 key OOPs questions for C programmers. Learn OOP's Concepts in. We have c. The abstract keyword can be used with class, methods, properties, indexers and events. Abstract members can only be declared inside an abstract class.

An abstract member can not be static or private. An abstract method can not be marked virtual. A concrete class can not inherit more than one abstract class, in other words multiple Inheritance is not possible. Without an abstract class, you can not implement the Template Method Pattern. Encapsulation is wrapping, it's just hiding properties and methods.

Encapsulation is used for hiding the code and data in a single unit to protect the data from the outside world. Class is the best example of encapsulation. Abstraction refers to showing only the necessary details to the intended user. No, an abstract class cannot be a sealed class. Because, the sealed modifier prevents a class from being inherited and the abstract modifier requires a class to be inherited. Yes, Abstract class can have constructor in C.

Abstract methods cannot be private in C. Yes, Abstract class can have static methods in C. No, Abstract class does not support multiple Inheritance.

Abstract class can have both abstract and non abstract methods. When you have a requirement where your base class should provide the default implementation of certain methods whereas other methods should be open to being overridden by child classes that time you have to use abstract classes.

Because, it has not fully implemented the class as its abstract methods can not be executed. If the compiler allows us to create the object for the abstract class, then you can invoke the abstract method using that object which cannot be executed by CLR at runtime.

Hence, to restrict the calling of abstract methods, the compiler does not allow you to instantiate an abstract class. You can define all static and non-static members including properties, fields, indexers and also abstract methods. Overloaded operators are functions with special names the keyword operator followed by the symbol for the operator being defined. Similar to any other function, an overloaded operator has a return type and a parameter list.

No, you cannot inherit Enum in C. Because, Enums are by default sealed. So, you can not inherit them. Yes, it is possible to achieve Method extension using Interface. Most of the LINQ is built around interface extension methods.

Interfaces were actually one of the driving forces for the development of extension methods. Since they can not implement any of their own functionality and extension methods are the easiest way of associating actual code with interface definitions.

It is also known as immutable values. Which are known at compile time and do not change their values at run time like in any function or constructor for the life of application till the application is running. It is also known immutable values. They are known at compile and run time and do not change their values at run time like in any function for the life of application till the application is running.

The static keyword is used to specify a static member. It means static members are common to all the objects and they do not get tied to a specific object. Static keyword can be used with classes, fields, methods, properties, operators, events, and constructors But, static can not be used with indexers, destructors, or types other than classes.

Key points about Static keyword, If the static keyword is applied to a class, all the members of the class must be static. Static methods can only access static members of same class. Static properties are used to get or set the value of static fields of a class. Static constructor cannot be parameterized. Access modifiers cannot be applied on static constructor. Because, it is always a public default constructor which is used to initialize static fields of the class.

Static Readonly type variable value can be assigned at runtime or at compile time and can be changed at runtime. Such variable's value can only be changed in the static constructor and can not be changed further.

It can change only once at runtime. Because, keyword 'this' returns a reference to the current instance of the class containing it.

Static methods or any static member do not belong to a particular instance. They exist without creating an instance of the class and call with the name of a class not by instance so you can not use this keyword in the body of static methods. What is Design Pattern in. Design Patterns in the object oriented world is a reusable solution to common software design problems that occur repeatedly in real-world application development.

It is a template or description for how to solve problems that can be used in many situations. Creational Patterns: It mainly deals with creation of Objects and Classes. Behavioral Patterns: It deals with Class and Object communication. That means they are concerned with the communication between class and objects. Which are the key Benefits of using Design Patterns? They give the developer a selection of tried and tested solutions to work with. They are language neutral and so can be applied to any language that supports object-orientation.

They aid communication by the very fact that they are well documented and can be researched if that is not the case. They have a proven track record as they are already widely used and thus reduce the technical risk to the project. They are highly flexible and can be used in practically any type of application or domain.

In C a static class can not implement an interface. While a single instance class needs to implement an interface for some business reason or IoC purpose, you can use the Singleton pattern without a static class. You can clone the object of Singleton but, you cannot clone the static class object. Singleton object stores in heap but, static object stores in stack.

A singleton can be initialized lazily or asynchronously while a static class is generally initialized when it is first loaded. No, you can not serialize Hashtable. Because, the. Singletons are not easy to handle with unit tests.

You cannot control their instantiation and they may retain state across invocations. But there is a key feature that can be used in C called interfaces that are used to achieve multiple inheritances in C. An interface is somewhat like a class but it only contains the declaration of the members but has no implementation. It is a reference type that only includes the signatures of methods, properties, or indexers. To implement an interface member, the corresponding member of the implanting class should be declared public, non-static, and have the same name and signature as an interface member.

In multi-dimensional arrays, the data or the array elements are stored in a tabular form or matrix form. These arrays are also called rectangular arrays due to the presence of rows and columns making it 2D or 3D.

A jagged array is a collection of arrays or we can say an array of arrays is called a jagged array. Become An Author. Forgot Password. Sign in. Toggle navigation. This article contains some of the very important or main questions that are asked about OOPs in C. What is OOP? What are the classes and objects? Difference between abstract class and interface in C? An abstract class is an incomplete class whose object cannot be instantiated. The abstract class allows us to create functionality that subclasses can implement or override.

We use a keyword abstract before we declare a class to be abstract. The interface is a blueprint of a class but it has no implementation. The things that are contained in the interface are the declarations of events, indexers, methods, or properties. An abstract class contains both declaration and definition part whereas an interface contains only the definition part.

A class can only use one abstract class but many interfaces can be used in a class. An abstract class can not implement multiple inheritances whereas an interface can do so. Explain early binding and late binding in C. Binding is the process in which association of method call to method body takes place.

The two types of binding are: Early or static binding In early binding, the methods and properties are detected and checked during compile time itself. Also, the compiler knows about what kind of object it is. If a method or property does not match or exist or it has some data type problem, then an exception is thrown by the compiler during the compile time.

In this article I will cover the list of best possible C Interview Questions and Answers of the C programming language and explain in as simple language as possible so it becomes understandable by every fellow programmer. C Interview Questions and Answers. What is C? What is Struct and Class in C?

Difference between String and StringBuilder in C? Concat s, "Khan" ;. Append "Mudassar" ;. Append "Khan" ;. What is Static function and example of in-built Static function in. What is Static class and its difference with Non-Static class? A Static class is a class that cannot be instantiated i. Static class. Non-Static class. What is Namespace in C? Give example of in-built Namespace in. A Namespace is used to organize classes.

Example of in-built. Net Namespace is the System Namespace.



0コメント

  • 1000 / 1000