(a) What is inheritance?
Show SolutionHide Solution↓
Inheritance is the mechanism by which a class acquires the properties and methods of another class.
(b) Name the operators listed below:
- <
- ++
- &&
- ? :
- Less than operator. (It is a relational operator)
- Increment operator. (It is an arithmetic operator)
- Logical AND operator. (It is a logical operator)
- Ternary operator. (It is a conditional operator)
(c) State the number of bytes occupied by char and int data types.
char occupies 2 bytes and int occupies 4 bytes.
(d) Write one difference between / and % operator.
/ operator computes the quotient whereas % operator computes the remainder.
(e) String x[] = {"SAMSUNG", "NOKIA", "SONY", "MICROMAX", "BLACKBERRY"};
Give the output of the following statements:
- System.out.println(x[1]);
- System.out.println(x[3].length());
The output of
System.out.println(x[1]);is NOKIA.x[1]gives the second element of the array x which is "NOKIA"The output of
System.out.println(x[3].length());is 8.x[3].length()gives the number of characters in the fourth element of the array x which is MICROMAX.