1
(a) Give one example each of a primitive data type and a composite data type.
Show SolutionHide Solution↓
- int
- array
(b) Give one point of difference between unary and binary operators.
unary operators operate on a single operand whereas binary operators operate on two operands.
(c) Differentiate between call by value or pass by value and call by reference or pass by reference.
| Call by value | Call by reference |
|---|---|
| Values of actual parameters are copied to formal parameters. | Reference of actual parameters is passed to formal parameters. |
| Changes made to formal parameters are not reflected back to actual parameters. | Changes made to formal parameters are reflected back to actual parameters. |
(d) Write a Java expression for:
$\sqrt{2as + u^2}$
Math.sqrt(2 * a * s + u * u)
(e) Name the type of error (syntax, runtime or logical error) in each case given below:
- Division by a variable that contains a value of zero.
- Multiplication operator used when the operation should be division.
- Missing semicolon.
- Runtime error
- Logical error
- syntax error