81.2k views
2 votes
Which of the following represent valid variable definitions? i. int n = -100; ii. int m = 2, p=4; iii. int 2k; iv. double x = 2 * m; v. float y = y * 2 vi. double d = 0.67F; vii. char c = '$'; viii. String str = 'hello'; ix. Int_marks_1; x. int n; m ;

User Srnvs
by
5.5k points

1 Answer

5 votes

Answer:

int n = -100;

ii. int m = 2, p=4;

vi. double d = 0.67F;

vii. char c = '$';

Step-by-step explanation:

A variable can be declared starting with a character,dollar sign or underscore not with an integer.you cannot use the same variable that you are declaring in it's definition.

For strings you have to use double quotes.

For declaring multiple variables you can do that by separating different variables by commas.

int a=4,b=44;

as long as they are of same data type.

In iv part if there is a variable m that is defined before variable x then it is valid.

User Sbgoran
by
5.2k points