1
visibility
class Teat
{
    public static void main(String[]args)
    {
        int b=3,k,r;
        float a=15.15,c=0;
        if(k==1)
        {
            r=(int)a/b;
            System.out.println(r);
        }
        else
        {
            c=a/b; 
            System.out.println(c);
        }
    }
}
  • 5.05

  • Compile time error:Possible Lossy Conversion

  • Compile time error : “variable k might not have been initialized”

  • 5

k is a local variable declared inside a method, we are using k in the if condition before initializing it i.e. before assigning any value to k. Due to this, the above code will generate a compile time error.