Professional Documents
Culture Documents
Objective
Pre-lab Exercise
1|Page
8. Which of these operators is used to allocate memory to array variable in Java?
A. malloc C. alloc
B. new D. new malloc
9. Which of these is an incorrect array declaration?
A. int arr[] = new int[5] C. int [] arr = new int[5]
B. int arr[] = new int[5] D. int arr[] = int [5] new
10. Which of these is necessary condition for automatic type conversion in Java?
A. The destination type is smaller than source type
B. The destination type is larger than source type
C. The destination type can be larger or smaller than source typ
D. None of the mentioned
11. If an expression contains double, int, float, long, then the whole expression will be
promoted into which of these data types?
A. long C. int
B. double D. float
12. Which of these class is superclass of String and StringBuffer class?
A. java.util C. java.lang
B. ArrayList D. None of the mentioned
13. Which of these operators can be used to concatenate two or more String objects?
A. + B. += C. & D. ||
2|Page
In-lab Exercise
3|Page
26. Write a Java program to count and print all the duplicates in the input string.
Sample Output:
The given string is: w3resource
The duplicate characters and counts are:
e appears 2 times
r appears 2 times
Post-lab Exercise
27. In the following Java code, which call to sum() method is appropriate?
class Output
{
4|Page