Introduction to C++ Programming - SIMP questions
Module 1
1. Explain the structure of a C++ program with syntax and example.
2. Define and explain the following terms with examples:
○ Objects
○ Classes
○ Methods
○ Abstraction
○ Encapsulation
3. List the features and benefits of Object-Oriented Programming (OOP).
4. Explain the importance of polymorphism in C++.
5. What is the need for an abstract class in C++? Discuss with an example.
6. Discuss objects and classes in brief.
7. Write down the syntax and example to create a class.
8. Define the terms: message passing, abstraction, inheritance, and polymorphism.
Module 2
1. Define tokens and explain their types with suitable examples.
2. List out the differences between structures and unions.
3. With an example C++ program, describe the scope resolution operator.
4. Explain operators in C++ with suitable examples.
5. Explain inline functions with a suitable C++ code segment.
6. Illustrate the use of inline functions with a program.
7. Write a C++ program to swap 2 values by writing a function that uses the call-by-reference
technique.
8. What does inheritance mean in C++? What are the different forms of inheritance? Give an
example for each.
Module 3
1. Explain parameterized constructors and copy constructors with suitable examples.
2. Explain destructors with syntax and a suitable example.
3. Explain single inheritance and write a C++ program to demonstrate student name, age, and
marks using single inheritance.
4. What is a constructor? How do we invoke a constructor function?
5. Describe the importance of destructors.
6. How is polymorphism achieved at (i) compile time and (ii) run time? Explain with examples.
7. Write a C++ program to demonstrate multilevel inheritance.
8. Explain the concept of multilevel inheritance with an example.
Module 4
1. With a neat diagram, explain the stream class hierarchy in C++.
2. Describe the following functions with their syntax for text files:
○ open()
○ close()
○ read()
○ write()
3. Write a C++ program to create a text file, check if it was created, and if so, write some text
into it and then read the text from the file.
4. Write a note on I/O streams.
5. What are the various types of files? What are the various modes in which a file can be
opened? Explain with an example program.
6. Explain the uses of ifstream and ofstream classes for file input and output.
7. Write a C++ program to create a text file, check if it was created, and if so, write some text
into it and then read the text from the file.
8. Explain how to read and write data to/from binary files.
Module 5
1. Define exception handling. Explain the exception-handling mechanism.
2. Explain the throwing and catching mechanism in exception handling.
3. Discuss "catch-all" exceptions with syntax and a suitable example program.
4. Write a function that throws a division-by-zero exception and catch it in a catch block.
5. Write a C++ program to demonstrate the usage of try, catch, and throw to handle
exceptions.
6. Define exceptions. Explain different blocks of exception handling.
7. Write a function that throws a division-by-zero exception and catch it in a catch block. Write
a C++ program to demonstrate the usage of try, catch, and throw to handle exceptions.
8. Discuss catching class type as an exception and rethrowing exceptions. Write a C++
program function that handles an array-of-bounds exception using exception handling.