OOP

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is a constructor?

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]) { }

Define destructor?

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.)

What is a class?

A set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality.

4 Basic Concepts of OOP

Abstraction. Encapsulation. Inheritance. Polymorphism.

What is an abstract class?

An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. Abstract classes are good for defining global definitions for your inherited classes, so you only need to define these definitions once.

5 types of constructors?

Default Constructor Parameterized Constructor Copy Constructor Static Constructor Private Constructor

What is encapsulation?

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 the THIS keyword?

Every instance method in every object in Java receives a reference named this when the method is invoked. The reference named this is a reference to the object on which the method was invoked. It can be used for any purpose for which such a reference is needed.

Difference between method overriding and method overloading?

In Overriding methods it will create two or more methods with same name and same parameter in different classes. while Overloading it will create more then one method with same name but different parameter in same class.

What is polymorphism?

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 operator overloading?

In programming, operator overloading—less commonly known as operator ad hoc polymorphism—is a specific case of polymorphism, where different operators have different implementations depending on their arguments. Operator overloading is generally defined by the language, the programmer, or both.

What is an inline function?

In the C and C++ programming languages, an inline function is one qualified with the keyword inline; this serves two purposes. Firstly, it serves as a compiler directive, which suggests (but does not require) that the compiler substitute the body of the function inline by performing inline expansion, The second purpose of inline is to change linkage behavior; the details of this are complicated.

What is OOP?

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.

What is an object?

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 are static functions?

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.

What is the final keyword?

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 is the super keyword?

The super keyword is a reference variable that is used to refer immediate parent class object. Whenever you create the instance of subclass, an instance of parent class is created implicitly i.e. referred by super reference variable.

What is inheritance?

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.


Ensembles d'études connexes

Med Surg I Prep U Chapter 59: Assessment and Management of Patients with Male Reproductive Disorders

View Set

Karatsuba Algorithm for Fast Multiplications 1 & 2

View Set

Business Law Chapter 32 - Partnerships

View Set

Chapter 62- Management of Patients with Cerebrovascular Disorders

View Set

Government Chapter 10 Section 3 review

View Set