Tcs 6
Tcs 6
3. What is the term given to the variable whose scope is beyond all the scopes
i.e., it can be accessed by all the scopes?
a. Universal Variable
b. Global Variable
c. External Variable
d. Auto Variable
Answer : b
4.Anu wants to make a function that is not bound to any identifier.which of the
following functions should she incorporate in her program?
a. Anonymous Function
b. Friend Function
c. Null Function
d. Global Function
Answer: a
5. Which of the following accessibility modes can be the specifier of a top level
class’?Top-level classes can only have public, abstract, and final modifiers, and
it is also possible to not define any class modifiers at all. This is called
default/package accessibility. Besides that, private, protected, and static
modifiers cannot be used when declaring top-level classes. Private, Protected,
Public, No Modifier
a. Only Private
b. Protected and Private
c. Public and No Modifier
d. Only No Modifier
Answer: c
6. Top-level classes can only have public, abstract, and final modifiers, and it is
also possible to not define any class modifiers at all. This is called
default/package accessibility. Besides that, private, protected, and static
modifiers cannot be used when declaring top-level classes.
Question 6 WRONG
Which of the following accessibility modes can be the specifier of a top level
class’?Top-level classes can only have public, abstract, and final modifiers, and
it is also possible to not define any class modifiers at all. This is called
default/package accessibility. Besides that, private, protected, and static
modifiers cannot be used when declaring top-level classes. Private, Protected,
Public, No Modifier
a. Only Private
b. Protected and Private
c. Public and No Modifier
d. Only No Modifier
Answer:c
7.Top-level classes can only have public, abstract, and final modifiers, and it is
also possible to not define any class modifiers at all. This is called
default/package accessibility. Besides that, private, protected, and static
modifiers cannot be used when declaring top-level classes.
Question 7 WRONG
Choose the correct answer. A pseudo-code which is similar to that of C++ and self-
explanatory An accessible member function or data member for an object are accessed
by the statement objectname.functionname or objectname. data member name
respectively. class brush { Private: integer size, colorcode function getdata( )
{–}//Statement 1 public: integer name // Statement 2 function putdata(){…} }
function main { brush b1, b2 print bl.name //Statement 3 b2.getdata() //Statement 4
} Deleting which line will correct the error in the code?
a.Statement 1
b.Statement 2
c.Statement 3
d.Statement 4
Answer:d
Explaination : Since, get data is private
9.Choose the correct answer Tanuj writes the code for a function that takes as
input n and calculates the sum of first n natural numbers. Function sum( n )
{ if(??) return 1 else return (n + sum(n-1)) end } Fill in ?? in the code.
a. n equals 1
b. n equals 2
c. n >= 1
d. n > 1
Answer: a
10.Choose the correct answer Shrishti writes the code for a function that computes
the factorial of the inputted number n. function factorial(n) { if(n equals 1)
return 1 else — MISSING STATEMENT — end } Fill in the missing statement.
a.return factorial(n-1)
b.return n*factorial(n)
c.return n*(n-1)
d.return n*factorial(n-1)
Answer: d