ExamVeda
Login
Home
Data Types and Variables
?

What is the output for the below code?
class A{
      int k;
      boolean istrue;
      static int p;
      public void printValue(){
            System.out.print(k);
            System.out.print(istrue);
            System.out.print(p);
      }
}

public class Test{
      public static void main(String argv[]){
            A a = new A();
            a.printValue();
      }
}

Answer & Solution
Correct Answer: Option A

Global and static variable need not be initialized before use. Default value of global and static int variable is zero. Default value of boolean variable is false. Remember local variable must be initialized before use.

Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.