Explain Form elements with example.
Explain Form elements with example. SOLUTION…. Form Elements in HTML Forms in HTML are used to collect user input such as text, numbers, emails, and choices. The <form> tag is the container, and inside it we use different form elements to accept different kinds of data. 1. <input> Element The <input> tag is the most […]
Explain inline, internal(embedded) and external stylesheet with example.
Explain inline, internal(embedded) and external stylesheet with example. SOLUTION…. 1. Inline Stylesheet In inline CSS, styles are written directly inside the HTML tag using the style attribute. It affects only that specific element. Useful for quick styling but not recommended for large projects because it reduces readability and reusability. Example: 2. Internal (Embedded) Stylesheet In […]
Explain any 5 basic tags of HTML.
Explain any 5 basic tags of HTML. SOLUTION…. 1. <html> Tag The <html> tag is the root element of an HTML document. It tells the browser that the content inside is written in HTML. All other tags must be placed inside <html> and </html>. Example: 2. <head> Tag The <head> tag contains metadata (data about […]
Explain the concept of default argument with an example.
Explain the concept of default argument with an example. SOLUTION…. Default arguments in C++ Definition (short):A default argument gives a parameter a value that the caller can omit. If the caller does not provide that argument, the compiler supplies the default at the call site. Why useful:They simplify calls and reduce the need for many […]
Explain inheritance and its types in detail.
Explain inheritance and its types in detail. SOLUTION…. Inheritance in C++ Definition:Inheritance lets a derived class reuse and extend the data/behaviour of a base class, modeling an “is-a” relationship (e.g., Dog is a Animal). It improves reuse, reduces duplication, and enables polymorphism. Basic syntax: Access effects (visibility mode): public inheritance: base public → derived […]
Explain in detail the concept of friend function.
Explain in detail the concept of friend function. SOLUTION…. Friend Function in C++ A friend function is a non-member function that is granted access to the private and protected members of a class by declaring it with the friend keyword inside that class. class A { int x; public: A(int v = 0) : x(v) […]
Explain Runtime polymorphism with an example.
Explain Runtime polymorphism with an example. SOLUTION…. Runtime Polymorphism (Dynamic Polymorphism) in C++ Definition:Runtime polymorphism lets a call made through a base-class pointer/reference invoke the overridden function of the derived object at runtime. In C++, this is achieved with virtual functions. How it works (in short): Mark a base-class function as virtual. Override it in […]
What are constructor and destructor? Explain copy and parameterized constructor With an example
What are constructor and destructor? Explain copy and parameterized constructor With an example SOLUTION…. ✨ Constructor and Destructor in C++ 📌 Constructor A constructor is a special member function of a class that is automatically called when an object is created. It has the same name as the class and no return type. Its purpose […]
What is operator overloading? Write different rules to overload operators. Also, explain Operator overloading with an example.
What is operator overloading? Write different rules to overload operators. Also, explain Operator overloading with an example. SOLUTION…. ✨ Operator Overloading in C++ 📌 Definition Operator overloading is a feature in C++ that allows programmers to redefine the way operators work for user-defined types (like classes and structures).In other words, we can give special meaning […]
Create an abstract class Employee with a pure virtual function calculateSalary(). Derive two classes FullTime and PartTime from it. Implement salary calculation logic differently in each class and display the salary using base class pointer.
Create an abstract class Employee with a pure virtual function calculateSalary(). Derive two classes FullTime and PartTime from it. Implement salary calculation logic differently in each class and display the salary using base class pointer. SOLUTION…. #include <iostream> using namespace std; // Abstract base class class Employee { protected: string name; int id; public: Employee(string […]