Knowee
Questions
Features
Study Tools

which of the following declarations is INCORRECT?A. String s = "Hi!";B. int[] ar = new int(3);C. double d = 1.3E + 21;D. double d = 1.3D;

Question

which of the following declarations is INCORRECT?A. String s = "Hi!";B. int[] ar = new int(3);C. double d = 1.3E + 21;D. double d = 1.3D;

🧐 Not the exact question you are looking for?Go ask a question

Solution

To determine which of the following declarations is incorrect, let's analyze each option step by step:

A. String s = "Hi!"; This declaration is correct. It creates a String variable named "s" and assigns it the value "Hi!".

B. int[] ar = new int(3); This declaration is incorrect. The correct syntax to create an array and specify its size is "new int[3]". Therefore, the correct declaration would be: int[] ar = new int[3];

C. double d = 1.3E + 21; This declaration is correct. It creates a double variable named "d" and assigns it the value 1.3 multiplied by 10 raised to the power of 21 (1.3 x 10^21).

D. double d = 1.3D; This declaration is correct. It creates a double variable named "d" and assigns it the value 1.3.

Therefore, the incorrect declaration is option B. int[] ar = new int(3).

This problem has been solved

Similar Questions

Which of the following statements are valid?a. int i = new int(30);b. double d[] = new double[30];c. char[] r = new char(1..30);d. int i[] = (3, 4, 3, 2);e. float f[] = {2.3, 4.5, 6.6};f. char[] c = new char()

Which of the following declarations are correct?  Please select all that apply.Group of answer choicespublic static void print(String... strings, double... numbers)public static void print(double... numbers, String name)public static double... print(double d1, double d2)public static void print(double... numbers)public static void print(int n, double... numbers)

Which of the following declarations is correct?int arr[3] = {1, 2, 3, 4};int arr[] = {1, 2, 3};int arr[3] = {1, 2};Both B and C

Which of the following are incorrect? Please select all that apply. Group of answer choicesint[] a = new int[2];int a[] = new int[2];int[] a = new int(2);int a = new int[2];int a() = new int[2];

Which of the following declaration is illegal?a.int a = 0, b = 1, c = 2; int array[3] = {a, b, c};b.int size = 3; int array[size];c.int size = 3; int array[size] = {1, 2, 3};d.In appropriate

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.