Languages-C & C Plus Plus [TCS Placement]: Sample Questions 31 - 33 of 119

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 31

C & C Plus Plus
Edit

Write in Short

Short Answer▾

Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

Explanation

  • Placing comment symbols / ⚹⚹ / around a code, also referred to as “commenting out” , is a way of isolating some codes that maybe causing errors in the program, without deleting the code.
  • The idea is, if the code is in fact correct- simply remove the comment symbols and continue on.
  • It also saves time and effort on having to retype the code which was deleted

Question 32

C & C Plus Plus
Edit

Write in Short

Short Answer▾

Why is it that not all header files are declared in every C program?

Explanation

  • The choice of declaring a header file at the top of each C program would depend on what commands or functions used in that program.
  • Since each header file contains different function definitions and prototype, only use those header files that contain the needed functions.
  • Declaring all header files in every program would increase the overall file size and load of the program, and is not a good programming style.

Question 33

C & C Plus Plus

Question

MCQ▾

How many types of polymorphisms are supported by c ++ ?

Choices

Choice (4)

a.

3

b.

1

c.

4

d.

2

Answer

d.

Explanation

  • Polymorphism provides ability to use an operator or function in different ways- providing different meanings to the operators or functions depending on context.
  • C ++ provides two different types of polymorphism.
    • run-time
    • compile-time
  • run-time:
    • The appropriate member function is selected while the program is running.
    • Run-time polymorphism is implemented with inheritance and virtual functions.
  • Compile-time:
    • Compiler is able to select the appropriate function for a particular call at compile-time.
    • Compile-time polymorphism is implemented with templates.
Given the Image is Define the Types of Polymorphisms

Developed by: