Languages [TCS Placement]: Sample Questions 23 - 24 of 131

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 23

Edit

Write in Short

Short Answer▾

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

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 24

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

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>intSquare(intx){
  2.     returnxx;
  3.     }intCube(intx){
  4.     returnxxx;
  5.     }intmain(){
  6.     intx =10;intchoice;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.         case0:ptr =Square; break;case1:ptr =Cube; break;
  12.     }
  13.     cout ≪ "The result is:" ≪ ptr(x) ≪ endl;return0;
  14. }
  • Output:

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

The result is: 100

Developed by: