Method Overriding Constructor Overloadingġ5.Questions and Answers on Object-Oriented Concepts?Īnswer: The section contains questions and answers on polymorphism, structures, enumeration, inheritance, method overloading and method overriding, abstract class and interfaces implementation. ![]() A potential example for printing “Hello World” to the console is detailed below.ġ4. Write a simple program that outputs “Hello World” to the console.Ī typical C# program consists of a namespace declaration, a class, methods, attributes, the main method, statements, expressions, and comments. For Loop Statements While Loop StatementsĪnswer: Garbage Collection is a process of releasing memory automatically occupied by objects which are no longer accessible.ĭescribe the basic construction of a C# program.The section contains questions on if, while, do-while, for, switch, continue and goto looping statements? It reduces the overhead of creating a new object. The mutable class should be used when string values will change.Īnswer: An object pool is a container of ready to use objects. ![]() Any modification to a string value results in a completely new string instance, thus an inefficient use of memory and extraneous garbage collection. Constructors are used for initialization chores.Īnswer: Immutable means string values cannot be changed once they have been created. The constructor has the same name as the class, and it can be overloaded via different signatures. Delegate is used to represent the reference of the methods of some return type and parameters.Īnswer: A constructor is a class member executed when an instance of the class is created. What do you mean by the delegate in C#?Īnswer: Delegates are type-safe pointers, unlike function pointers as in C++. In the ArrayList, elements are not automatically sorted.Ĩ. You can add and remove the elements from an ArrayList at runtime. Run Time Polymorphism: It is also known as late binding or method overriding or dynamic polymorphism.Īnswer: ArrayList is a dynamic array. There are two types of polymorphism in C#.Ĭompile Time Polymorphism: It is also known as early binding. What is the difference between early binding and late binding in C#?Īnswer: Early binding and late binding are the concepts of polymorphism. If there is any object available within the allowed limit, it will return the object (value object), otherwise, a new object will be created and give you back.Ħ. Whenever there is a request for a new object, the factory method will look into the object pool (we use Queue object). We will have a factory method, which will take care of the creation of objects. Whenever there is a request for a new object, the pool manager will take the request and it will be served by allocating an object from the pool.Īnswer: We are going to use a Factory pattern for this purpose. If our application involves some time-consuming processes then it’s better to use Multithreading., which involves multiple threads.Īnswer: Object Pool is nothing but a container of objects that are ready for use. Thread is used to define the different or unique flow of control. Net Framework 2.0 and it allows us to split the business logic into multiple files with the same class name along with “partial” keyword.Īnswer: Thread is an execution path of a program. Obviously, there are principles like Encapsulation, Polymorphism, Abstraction, and Inheritance, but these are the consequence and not the generating force behind the OO paradigm in C#.Īnswer: Partial classes concept added in. The two most fundamental core concepts on which OO has been built upon in C# are this pointer and Dynamic Dispatch. What is really important is to understand in what grounds OO is built upon, or in other words, what are the foundations of OO programming. ![]() ![]() Principles are crucial but they are not the most important aspect of what OO actually is. Although this is true, it doesn’t really explain the fundamental core of what OO is and what its benefits are. What are the fundamental principles of OO programming?Īnswer: As a developer, you might be tempted to answer that it comprises things like Encapsulation, Polymorphism, Abstraction, and Inheritance.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |