Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 46 - 47 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 46

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is late bound function call and early bound function call? Differentiate.

Explanation

Understanding of Part of Binding
  • All virtual functions have late binding.
  • All non-virtual functions will have early binding.
  • Early binding happens at compile time.
  • Late binding happens at runtime based on type of object referred a by a pointer variable.
  • For example: base class B and derived class D have both implemented a method F () .

    B ⚹ ptr = new D;

    ptr ⇾ F () ;

  • If F () is virtual then D՚s implementation is called.
  • If F () is not virtual than B՚s implementation is called.

Question 47

C & C Plus Plus
Edit

Describe in Detail

Essay▾
  1. #include<studio.h>
  2. main ()
  3. {
  4.     chars[] ={ ‘a’ ‘b’ ‘c’ ‘’ ‘c’ ‘⧵0’ };
  5.     char ⚹p, ⚹str, ⚹str1;
  6.     p =&s[3];
  7.     str =p;
  8.     str1 =s;
  9.     printf ( “%d” ++ ⚹p ++ +⚹ str1 − 32);
  10. }

Explanation

  • In a program
    Table Shows the Program
    char s [] = { ‘a’ ‘b’ ‘c’ ‘’ ‘c’ ‘⧵0’ } ;Given the character array and values
    char ⚹ p, ⚹ str, ⚹ str1;Given three pointer variables
    p = &s [3] ;P is pointing to character ‘’
    str1 = s;Str1 is pointing to character ‘a’
    printf ( “% d” ++ ⚹ p ++ +⚹ str1 − 32) ;
  • ++ ⚹ p , here “p is pointing to ‘’ and that is incremented by one” .
  • The ASCII value of ‘’ is 10, which is then incremented to 11.
  • The value of ++ ⚹ p is 11
  • ++ ⚹ str1 is pointing to ‘a’ that is incremented by 1 and it becomes ‘b’
    • ASCII value of ‘b’ is 98
  • Now performing (11 + 98 - 32) ,
  • We get 77

Developed by: