Java - What is the output: blank final instance variable?


What is the output of the following code?

class Test {
  private final int y; 

public class Main {

  public static void main(String[] args) {
    new Test(); 

Click to view the answer

private final int y; //The blank final field y may not have been initialized


The blank final instance variable y is never initialized.

The compiler would add a default constructor, but it will not initialize y inside the constructor.

Related Quiz