UGC NET COMPUTER SCIENCE SOLVED PAPERS 2014-16 - UGC NET Computer Science Paper 2 JULY 2016

11. Given i = 0, j = 1, k = –1 x = 0.5, y = 0.0 What is the output of the following expression in C language ? x * y < i + j || k

  • Option : C
  • Explanation :
    = x * y < i + j || k
    = 0.5 * 0.0 < 0 + 1 || -1
    = 0.0 < 0 + 1 || -1
    = 0.0 < 1 || -1
    = 1 || -1
    = 1
    So, option (C) is correct.
Cancel reply
Cancel reply

13. Which one of the following is correct, when a class grants friend status to another class?

  • Option : B
  • Explanation :
  • When a class grants friend status to another class then all member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship.
  • The member functions of the class generating friendship can access the members of the friend class.Incorrect statement.
  • Class friendship is not reciprocal to each other.
  • So, option (B) is correct.
Cancel reply
Cancel reply

14. When a method in a subclass has the same name and type signatures as a method in the superclass, then the method in the subclass _____ the method in the superclass

  • Option : D
  • Explanation :
  • When a method in a subclass has the same name and type signatures as a method in the superclass, then the method in the subclass overrides the method in the superclass.
  • Overloading allows different methods to have same name, but different signatures where signature can differ by number of input parameters or type of input parameters or both. Overloading is related to compile time (or static) polymorphism..
  • Friend Class A friend class can access private and protected members of other class in which it is declared as friend..
  • The capability of a class to derive properties and characteristics from another class is called Inheritance.
  • So, option (D) is correct.
Cancel reply
Cancel reply

15. What is the value returned by the function f given below when n = 100? int f (int n) { if (n = = 0) then return n; else return n + f(n-2); }

  • Option : A
  • Explanation :
    We have function:
    int f (int n)
    { if (n = = 0) then return n;
    else
    return n + f(n-2);
    }
    we have to find output for n = 100 i.e int f (100) { if (n = = 0) then return n; //failure// else return 100 + f (98) { if (n = = 0) then return n; //failure// else return 98 + f (96) { if (n = = 0) then return n; //failure// else return 96 + f (94).......................f(0);// It will be a AP series of 100 , 98, 96,.........0// ; }; }; } Sum of series when we know first and last term and no of terms: Sn = n / 2 * (first term + last term) i.e. 51 / 2 * (100 + 0). = 51 * 50 = 2550. So, option (A) is correct.
Cancel reply
Cancel reply