Hiremee Quiz on Procedure, functions and scope with Answers

Question 1

Time: 00:00:00
What is the difference between a function and a method?

Function is a named code unlike method which is a part of an object

Function is a named code unlike method which is a part of an object

Function contained in an object is called a method

Function contained in an object is called a method

Function cannot change variables outside its scope unlike method

Function cannot change variables outside its scope unlike method

There is no difference between the two

There is no difference between the two

Once you attempt the question then PrepInsta explanation will be displayed.

The function is something that we d t decrease the size of the code or to understand the long code in titbits but the methods are declared by the language to declare themselves to perform certain operations for the required task and they need to be called by the object.

Start

Question 2

Time: 00:00:00
```Consider the following code:
function modify(a,b)
{

Integer c,d=2
c= a*d+ b
return c
}

function calculate()
{

integer a = 5, b = 20, c
integer d= 10
c = modify(a, b);
c = c+ d
print c
}```

80

80

40

40

32

32

72

72

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 3

Time: 00:00:00
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?

Universal Variable

Universal Variable

Global Variable

Global Variable

External Variable

External Variable

Auto Variable

Auto Variable

Once you attempt the question then PrepInsta explanation will be displayed.

A global variable is a programming language construct, a variable type that is declared outside any function and is accessible to all functions

Start

Question 4

Time: 00:00:00
Anu wants to make a function that is not bound to any identifier. Which of the following functions should she incorporate in her program?

Anonymous Function

Anonymous Function

Friend Function

Friend Function

Null Function

Null Function

Global Function

Global Function

Once you attempt the question then PrepInsta explanation will be displayed.

An anonymous function is a function that was declared without any named identifier to refer to it. As such, an anonymous function is usually not accessible after its initial creation. Normal function definition: function hello() { alert(\'Hello world\'); } hello(); Anonymous function definition: var anon = function() { alert(\'I am anonymous\'); } anon();

Start

Question 5

Time: 00:00:00
Which of the following accessibility modes can be the speciﬁer 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

Only Private

Only Private

Protected and Private

Protected and Private

Public and No Modifier

Public and No Modifier

Only No Modifier

Only No Modifier

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 6

Time: 00:00:00
Which of the following accessibility modes can be the speciﬁer 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

Only Private

Only Private

Protected and Private

Protected and Private

Public and No Modifier

Public and No Modifier

Only No Modifier

Only No Modifier

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 7

Time: 00:00:00
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?

Statement 1

Statement 1

Statement 2

Statement 2

Statement 3

Statement 3

Statement 4

Statement 4

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 8

Time: 00:00:00
function MyDisplay(string MyStr) //statement 1
{
print "Hello !"
print MyStr
return 1 // statement 2
}
function main() //statement 3
{
string str= "Mickey"
MyDisplay(str) // statement 4
}

Which statement will generate an error.

Statement 1

Statement 1

Statement 2

Statement 2

Statement 3

Statement 3

Statement 4

Statement 4

Once you attempt the question then PrepInsta explanation will be displayed.

Start

Question 9

Time: 00:00:00
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.

n equals 1

n equals 1

n equals 2

n equals 2

n >= 1

n >= 1

n > 1

n > 1

Once you attempt the question then PrepInsta explanation will be displayed.

n equals 1....only satisfies the condition

Start

Question 10

Time: 00:00:00
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.

return factorial(n-1)

return factorial(n-1)

return n*factorial(n)

return n*factorial(n)

return n*(n-1)

return n*(n-1)

return n*factorial(n-1)

return n*factorial(n-1)

Once you attempt the question then PrepInsta explanation will be displayed.