Languages-C & C Plus Plus [TCS Placement]: Sample Questions 20 - 21 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 20

Write in Short Short Answer▾

What are the different file extensions involved when programming in c?

Edit

Explanation

  • Source code files in C are saved with . c file extension.
  • Header files or library files have the . h file extension.
  • Every time a program source code is successfully compiled, it creates an . obj object file, and an executable . exe file.

Question 21

Question MCQ▾

Which of the following concepts means determining at runtime what method to invoke?

Choices

Choice (4)

a.

Data hiding

b.

Dynamic typing

c.

Dynamic binding

d.

Dynamic loading

Edit

Answer

c.

Explanation

  • Dynamic binding means determining at runtime the method to invoke.
  • In OOPs Dynamic Binding refers to linking a procedure call to the code that will be executed- this is done at run time.
  • The code associated with the procedure in not known until the program is executed, which is also known as late binding.
  • Example
  1. #include <iostream>int Square(int x){
  2. return xx;
  3. }int Cube(int x){
  4. return xxx;
  5. }int main(){
  6. int x =10;int choice;do{
  7. cout "Enter 0 for square value, 1 for cube value:";cin choice;
  8. }
  9. while (choice <0 || choice >1);int (⚹ptr) (int);
  10. switch (choice){
  11. case 0:ptr =Square; break;case 1:ptr =Cube; break;
  12. }
  13. cout "The result is:" ptr(x) ≪ endl;return 0;
  14. }
  • Output:

Enter 0 for square value, 1 for cube value: 0

The result is: 100