0
0
Which one of the following is a valid statement?
Which one of the following is a valid statement?
A). char[] c = new char();
B). char[] c = new char(4);
C). char[] c = new char(4);
D). char[] c = new char[];
This Question has 1 answers.
char[] c = new char[5];
The syntax for declaring and creating an array variable in java is:
dataType[] arrayRefVar = new dataType[arraySize];
Thus, option (A) and option (C) is syntactically wrong as parentheses( ( ) ) is used instead of square brackets( [ ] ).
Option (D) is incorrect as the size of the array is missing.
Similar Questions
- In an alloy, zinc and copper are in the ratio 1 : 2. In the second alloy, the same elements are in the ratio 2 : 3. If these two alloys be mixed to form a new alloy in which two elements are in the ratio 5:8, the ratio of these two alloys in the new allow
- Study the following information carefully to answer these questions.A vehicle starts from point P and run 10 km towards North. It takes a right turn and runs 15 km. Now it runs 6 km after taking a left turn. Finally, it takes a left turn, runs 15 km and s
- Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct?1. A a = new A();2. A a = new B();3. B b = new A();4. B b = new B();
- Study the following information carefully and answer the questions given below:Each of the six persons, P, Q, R. S. T and U has travelled to different number of countries. R has travelled to more number of countries than only S and T. Q has travelled to m
- Read the following information to answer this question : Four friends A, B, C and D are studying together in class 10+2. A and B are good in Hindi but poor in English. A and C are good in Sanskrit but poor in Maths. C and D are good in English but