6 years ago in Java Strings

What will happen if you try to compile and run the following code?
public class Q {

public static void main(String argv[]){

int anar[]=new int[5];

System.out.println(anar[0]);

}

}

[A] Error: anar is referenced before it is initialized
[B] null
[C] 0
[D] 5
Loading...
Next Question

Create your Digital Resume For FREE on your name's sub domain "yourname.wcard.io". Register Here!


Overall Stats

Attempted 342
Correct 92
Incorrect 113
Viewed 137

Answers

Guest
Guest
Sagar Manchi
Sagar Manchi - 1 month ago

Sagar Manchi is saying 5 is correct answer

keziah
keziah - 3 months ago

keziah from Colombo, Sri Lanka is saying 5 is correct answer

Onyinyechi stella
Onyinyechi stella - 5 months ago

Onyinyechi stella is saying null is correct answer

saliha rchid
saliha rchid - 7 months ago

saliha rchid from Casablanca, Morocco is saying Error: anar is referenced before it is initialized is correct answer

Salah Eddine
Salah Eddine - 7 months ago

Salah Eddine from Casablanca, Morocco is saying 0 is correct answer

Related Questions

String is an________

  • [A] class
  • [B] Variable
  • [C] Array
  • [D] Data type

What will happen if you try to compile and run the following code ?
public class MyClass {

    public static void main(String arguments[]) { 

    }

    public void amethod(String[] arguments) { 

    }

}

  • [A] error Can't make static reference to void method.
  • [B] error method main not correct
  • [C] error array must include parameter
  • [D] amethod must be declared with String

Which of the following statements are incorrect?

  • [A] String is a class
  • [B] Strings in java are mutable.
  • [C] Every string is an object of class String.
  • [D] Java defines a peer class of String, called StringBuffer, which allows string to be altered.