1.
The following method
computes and returns the value of x
raised to the power y. Some parts of the method have been replaced by n where n
is from 1 to 4. Fill in these parts so
that the method works correctly :
public
int power(int x, int y)
{
int i,pro;
?1?
= x;
for(i=1;
i< ?2?; i++)
pro*=?3?;
return
?4?;
} (4)
2.
An array element is
accessed using :
a) the dot operator b) an
element name
c) an element number d) the array
size
3.
Which of the
following is not an entry controlled loop ?
a) for b) do while
c) while d) none of the above
4.
Which of the
following can be accessed through objects of their own class type ?
a) public b) private
c) protected d) non-private
5.
When an argument is
passed by reference :
a) a variable is created within the function to hold the
argument’s value
b) the function cannot access the argument’s value
c) a variable is created in the calling function to hold the
argument’s value
d) the function accesses the argument’s original value
(1x4)
6.
Differentiate
between :
a) static method
& instance method
b) byte code & machine code
c) pure function & impure function
d) constructer & method (2x4)
7.
When is it possible
to declare a method as private ? (1)
8.
What are identifiers
? (1)
9.
What is the default
value for a String ? (1)
10.
Which operator is
used to associate an object with a method ? (1)