Languages [3i Infotech Placement]: Sample Questions 100 - 102 of 546

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

Question 100

Languages
Edit

Write in Short

Short Answer▾

What restrictions are placed on method overloading?

Explanation

Restriction imposed on Method Overloading are

a) should done within the same class.

b) Should have same name of overloading method.

c) Arguments or parameter should be different irrespective of return type.

Question 101

Edit

Describe in Detail

Essay▾
  1. main ()
  2. {
  3.     floatme =1.1;
  4.     doubleyou =1.1;
  5.     if (me == you)
  6.     printf ( “IloveU” );
  7.     else
  8.     printf ( “IhateU” );
  9. }

Explanation

  • For floating point numbers (float, double, long double) the values cannot be predicted exactly
  • Float takes 4 bytes
  • Double and long double takes 10 bytes
  • So, float stores 0.9 with less precision than long double.
  • So in the program
    Table Shows the Program
    float me = 1.1Define float value
    double you = 1.1Define double value
    if (me == you)Apply if condition for float and double value
  • Float me = 1.1 and double you = 1.1 is not same
  • So, apply the else condition and print I hate U
  • Rule of Thumb: Never compare when using floating point numbers with relational operators (== , >< ⇐ >= , =) .

Question 102

Edit

Write in Short

Short Answer▾

What is difference between pass by reference and pass by value?

Explanation

Difference between Pass by Value and Pass by Reference
Pass by valuePass by reference
Passes an argument by valuePasses an argument by reference.
Sends copy of the data.Passes memory address of the data that is stored.
Change by the called function does not affect the actual value.Changes done by the called function effect the original data.

Developed by: