When an object is destroyed, the destructors are called. Destructors are not as necessary in Python as they are in C++ because Python has a garbage collector that manages memory automatically. The _del_() method in Python is known as a destructor method. When an object is garbage collected, or when all references to the object […]
December 12, 2022 | python | No comments
What is a Virtual Destructor? Deleting a derived class object with a non-virtual destructor using a pointer of the base class type results in undefined behavior. While deleting instances of the derived class using a base class pointer object, a virtual destructor is used to free up the memory space allocated by the derived class […]
October 28, 2022 | C++ | No comments
If we inherit a class from another class and create an object of the derived class, it is obvious that the derived class’s default constructor will be invoked, but first, the default constructors of all base classes will be invoked. The data members and member functions of the base class are automatically included in the derived […]
October 23, 2022 | C++ | No comments
A copy constructor is a type of constructor that creates a copy of another object. If we want one object to resemble another, we can use a copy constructor. If no copy constructor is written in the program, the compiler will supply its own copy constructor.The copy constructor is used to − Initialize one object […]
October 19, 2022 | C++ | No comments
When the static keyword is used, variable or data members or functions can no longer be changed. It is allocated for the lifetime of the program. The static keyword can be used with: Static Variables: Variables in a function, Variables in a class Static Members of Class: Class objects and Functions in a class Static Variables in […]
October 14, 2022 | C++ | No comments
Constructor: A constructor is a special member function of a class and shares the same name as of class, which means the constructor and class have the same name. The compiler calls the constructor whenever a class object is created; it allocates memory to the object and initializes class data members with default values or […]
October 13, 2022 | C++ | No comments
In java.lang package, there is a wrapper class Boolean. A value of the primitive type boolean is wrapped in an object by the Boolean class. An object of type Boolean has a single field with the type boolean. Constructors for creating Boolean object: Methods of Boolean Wrapper class: Methods Description boolean booleanValue() Returns a primitive boolean […]
August 27, 2022 | Java | No comments
TreeSet is a widespread Java implementation of the SortedSet interface that employs a Tree for storage. Whether an explicit comparator is provided, a set maintains the ordering of the components using their natural ordering. If the Set interface is to be correctly implemented, this must be compatible with equals. TreeSet class Declaration: The following are […]
July 26, 2022 | Java | No comments
What are Chained Exceptions? One exception can be related to another using chained exceptions. We can use the chained exception mechanism in situations where we frequently need to throw a custom exception but want to retain the specifics of an original exception. Constructors Of Throwable class Which support chained exceptions in java : Throwable(Throwable cause): Where […]
June 27, 2022 | Java | No comments
The Java class StringBuilder represents a mutable string of characters. The StringBuilder class offers a substitute for the String Class in Java since it constructs a mutable sequence of characters instead of an immutable one as the String Class does. The functions of the StringBuilder and StringBuffer classes are extremely similar because both create changeable […]
June 17, 2022 | Java | No comments