(a) State the total size in bytes, of the arrays a[4] of char data type and p[4] of float data type.
Show SolutionHide Solution↓
Size of char a[4] is 4 × 2 = 8 Bytes.
Size of float p[4] is 4 × 4 = 16 Bytes.
(b) (i) Name the package that contains Scanner class.
(ii) Which unit of the class gets called, when the object of the class is created?
(i) java.util
(ii) Constructor
(c) Give the output of the following:
String n = "Computer Knowledge";
String m = "Computer Applications";
System.out.println(n.substring(0, 8).concat(m.substring(9)));
System.out.println(n.endsWith("e"));
ComputerApplications
true
n.substring(0,8) returns the substring of n starting at index 0 till 7 (i.e. 8 - 1 = 7) which is "Computer". m.substring(9) returns the substring of m starting at index 9 till the end of the string which is "Applications". concat() method joins "Computer" and "Applications" together to give the output as ComputerApplications.
(d) Write the output of the following:
- System.out.println(Character.isUpperCase('R'));
- System.out.println(Character.toUpperCase('j'));
- true
- J
(e) What is the role of keyword void in declaring functions?
The keyword 'void' signifies that the function doesn't return a value to the calling function.