Languages [TCS Placement]: Sample Questions 43 - 45 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 43

Question

MCQ▾

Which of the following approach is adapted by c ++ ?

Choices

Choice (4)

a.

Left-right

b.

Top-down

c.

Bottom-up

d.

Right-left

Answer

c.

Explanation

  • C ++ follows bottom up approach- gathering small components that do basic actions joined to make full program work.
  • Components are joined by custom code to come up to main method.
  • In bottom up approach we can define main anywhere in our program.
  1. {
  2.     Initialization;
  3.     Fun()
  4.     {
  5.     }
  6. }
  7. Main()
  8. {
  9.     ……..
  10. }

Question 44

Edit

Describe in Detail

Essay▾

What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?

Explanation

  • If the index of the array size is exceeded, the program will crash. C does not check for buffer overflow and hence some random memory will be written in the process space causing undefined behaviour
  • Example:
  1. #include<stdio.h>
  2. intmain()
  3. {
  4.     intarr[2];
  5.     arr[3]=10;
  6.     printf(“%d”,arr[3]);
  7.     return0;
  8. }
  • Output:

10

Question 45

Question

MCQ▾

Which of the following concepts means adding new components to a program as it runs?

Choices

Choice (4)

a.

Dynamic typing

b.

Dynamic binding

c.

Data hiding

d.

Dynamic loading

Answer

d.

Explanation

  • Dynamic loading means adding new components to a program as it runs.
  • The dynamic loaded block (or library) is loaded into ram only on the execution time.
  • Here code is loaded only when it requires to be executed.
  • This type of loading takes place in object oriented programming languages like c ++ , java etc. achieving better memory space utilization is achieved.
Given the Image is Define the Dynamic Loading Example

Developed by: