PPL Q&a
PPL Q&a
PPL Q&a
Set Pointers to NULL= After freeing memory, set the pointer to NULL
In C++, use smart pointers like std::unique_ptr or std::shared_ptr
Use Ownership Semantics- Design your program to have clear ownership of
resources.
Shallow binding means a function uses the most recent value of a variable when
it's called.
Deep binding means a function remembers the value of a variable from when it
was created, not when it's called.
12) Define the term “Constructor”.
A constructor is a special method in a class that is automatically called when you
create an object (an instance) of that class. Its main job is to set up the initial values
of the object's properties.
Precedence: is the rule that determines the order in which different operations (like
addition or multiplication) are performed in an expression.
Associativity: Associativity is the rule that determines the order in which operators of
the same precedence are evaluated in an expression. It tells you how to group
operations when they are next to each other.
Orthogonality: in programming languages means that different features work
independently of each other. You can use them together without causing
unexpected problems.
String
Binding: is how we connect names (like variables and functions) to their values or
actions in programming. It tells the computer what a name refers to.
Example encapsulation:
class Employee {
private:
int salary;
public:
void setSalary(int s) {
salary = s;
}
int getSalary() {
return salary;
}
};
18) What is enumeration type? Give design issues for enumeration type.
19) Explain implementation of Single Inheritance with suitable example.
The inheritance in which a single derived class is inherited from a single base class is
known as the Single Inheritance
Simple Example: Animals
Imagine we have a general class called Animal, and a specific class called Dog that
inherits from Animal.
20) What is Binding Time? Explain the different binding times at which binding
decisions can be made.