Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
166 views2 pages

Advanced C++ Quiz

Uploaded by

Raghav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
166 views2 pages

Advanced C++ Quiz

Uploaded by

Raghav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

### Object-Oriented Programming Questions

11. Which of the following is not a feature of Object-Oriented Programming in C++?


- A) Encapsulation
- B) Inheritance
- C) Polymorphism
- D) Compilation
- Answer: D) Compilation

12. How do you declare a class in C++?


- A) class MyClass {};
- B) class MyClass();
- C) MyClass class {};
- D) def class MyClass {};
- Answer: A) class MyClass {};

13. Which keyword is used to inherit a class in C++?


- A) inherit
- B) extends
- C) derives
- D) public
- Answer: D) public

14. What is the default access speci er for members of a class in C++?
- A) private
- B) public
- C) protected
- D) internal
- Answer: A) private

15. Which of the following is true about constructors in C++?


- A) A constructor has the same name as the class
- B) A constructor can have a return type
- C) A constructor is called automatically when an object is created
- D) A and C
- Answer: D) A and C

### Advanced C++ Questions

16. What is a virtual function in C++?


- A) A function that is not real
- B) A function that can be overridden in a derived class
- C) A function that is private
- D) A function that is used for input/output
- Answer: B) A function that can be overridden in a derived class

17. Which of the following is used to handle exceptions in C++?


- A) try/catch
- B) try/catch/ nally
- C) try/ nally
- D) All of the above
- Answer: A) try/catch

18. What is the output of the following code?


```cpp
int arr[] = {1, 2, 3, 4, 5};
cout << arr[2];
```
- A) 1
- B) 2
fi
fi
fi
- C) 3
- D) 4
- Answer: C) 3

19. Which of the following is not a type of inheritance in C++?


- A) Single
- B) Multiple
- C) Hybrid
- D) Parallel
- Answer: D) Parallel

20. What is the output of the following code?


```cpp
int a = 10;
int b = 20;
int *p = &a;
int *q = &b;
cout << *p + *q;
```
- A) 10
- B) 20
- C) 30
- D) Error
- Answer: C) 30

You might also like