


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



What is OOP? - ANSWER Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data. 4 Basic Concepts of OOP - ANSWER Abstraction. Encapsulation. Inheritance. Polymorphism. What is a class? - ANSWER A set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality. What is an object? - ANSWER Objects are created from Classes, in C#, is an instance of a class that is created dynamically. Object is also a keyword that is an alias for the predefined type System. What is encapsulation? - ANSWER Encapsulation is the packing of data and functions into a single component. The features of encapsulation are supported using classes in most object-oriented programming languages, although other alternatives also exist. It allows selective hiding of properties and methods in an object by building an impenetrable wall to protect the code from accidental corruption. What is polymorphism? - ANSWER In programming languages and type theory, polymorphism is the provision of a single interface to entities of different types. A polymorphic type is a type whose operations can also be applied to values of some other type, or types.
What is inheritance? - ANSWER inheritance is when an object or class is based on another object or class, using the same implementation (inheriting from a class) specifying implementation to maintain the same behavior (realizing an interface; inheriting behavior). It is a mechanism for code reuse and to allow independent extensions of the original software via public classes and interfaces. What is a constructor? - ANSWER A constructor is special method of the class that will be automatically invoked when an instance of the class is created is called as constructor. Constructors are mainly used to initialize private fields of the class while creating an instance for the class. When you are not creating a constructor in the class, then compiler will automatically create a default constructor in the class that initializes all numeric fields in the class to zero and all string and object fields to null. Syntax. [Access Modifier] ClassName([Parameters]) { } 5 types of constructors? - ANSWER Default Constructor Parameterized Constructor Copy Constructor Static Constructor Private Constructor Define destructor? - ANSWER A destructor is a method which is automatically invoked when the object is destroyed. Its main purpose is to free the resources (memory allocations, open files or sockets, database connections, resource locks, etc.)
Abstract classes are good for defining global definitions for your inherited classes, so you only need to define these definitions once. What is the final keyword? - ANSWER The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final can be: variable, method, class. The final keyword can be applied with the variables, a final variable that have no value it is called blank final variable or uninitialized final variable. It can be initialized in the constructor only. The blank final variable can be static also which will be initialized in the static block only. What are static functions? - ANSWER Static functions and classes require no instantiation. It means that you can use these classes, functions, and parameters at-will without creating and instantiating the object. Static functions are beneficial when you need quick execution of functions that don't need other parts of the containing class. You cannot use non-static classes with static functions.