5 years ago in Java Strings

What is the output of the code ?
public class AQuestion{

private int i = j;

private int j = 10;

public static void main(String args[]){

System.out.println((new AQuestion()).i);

}

}

[A] Compiler error complaining about access restriction of private variables of AQuestion.
[B] Compiler error complaining about forward referencing.
[C] No error - The output is 0;
[D] No error - The output is 10;
Loading...
Next Question

Overall Stats

Attempted 261
Correct 59
Incorrect 103
Viewed 99

Answers

Guest
Guest
bruh
bruh - 1 month ago

bruh from Guwahati, India is saying Compiler error complaining about forward referencing. is correct answer

Assaad Amine
Assaad Amine - 1 month ago

Assaad Amine from Casablanca, Morocco is saying Compiler error complaining about access restriction of private variables of AQuestion. is correct answer

Zo Go
Zo Go - 1 month ago

Zo Go from Casablanca, Morocco is saying No error - The output is 0; is correct answer

Vaibhav Bisht
Vaibhav Bisht - 1 month ago

Vaibhav Bisht from Dehradun, India is saying No error - The output is 0; is correct answer

Awa Kone
Awa Kone - 1 month ago

Awa Kone from Berrechid, Morocco is saying Compiler error complaining about access restriction of private variables of AQuestion. is correct answer

Related Questions

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.