php mcq questions with answers


                                

Which of the following statements are correct?

  1. The conditional operator (?:) returns one of two values depending on the value of a Boolean expression.
  2. The as operator in C#.NET is used to perform conversions between compatible reference types.
  3. The &* operator is also used to declare pointer types and to dereference pointers.
  4. The -> operator combines pointer dereferencing and member access.
  5. In addition to being used to specify the order of operations in an expression, brackets [ ] are used to specify casts or type conversions.

A.1, 2, 4
B.2, 3, 5
C.3, 4, 5
D.1, 3, 5
E.None of these
                                

Which of the following statements are correct?

  1. An argument passed to a ref parameter need not be initialized first.
  2. Variables passed as out arguments need to be initialized prior to being passed.
  3. Argument that uses params keyword must be the last argument of variable argument list of a method.
  4. Pass by reference eliminates the overhead of copying large data items.
  5. To use a ref parameter only the calling method must explicitly use the ref keyword.

A.1, 2
B.2, 3
C.3, 4
D.4, 5
E.None of these
                                

A function returns a value, whereas a subroutine cannot return a value.

A.True
B.False
                                

Which of the following statements are correct about functions and subroutines used in C#.NET?

  1. A function cannot be called from a subroutine.
  2. The ref keyword causes arguments to be passed by reference.
  3. While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method.
  4. A subroutine cannot be called from a function.
  5. Functions and subroutines can be called recursively.

A.1, 2, 4
B.2, 3, 5
C.3, 5
D.4, 5
E.None of these
                                

Which of the following statements are correct?

  1. C# allows a function to have arguments with default values.
  2. C# allows a function to have variable number of arguments.
  3. Omitting the return value type in method definition results into an exception.
  4. Redefining a method parameter in the method's body causes an exception.
  5. params is used to specify the syntax for a function with variable number of arguments.

A.1, 3, 5
B.3, 4, 5
C.2, 5
D.4, 5
E.None of these