Consider the following code:

Consider the following code:

public class Bay extends Lake {
public void method1() {
     System.out.println("Bay 1");
     super.method2();
}

  public void method2() {
       System.out.println("Bay 2");
   }
}

//*********************************

class Pond {
  public void method2() {
         System.out.println("Pond 2");
  }
}

//**************************

class Ocean extends Bay {
        public void method2() {
                 System.out.println("Ocean 2");
        }
}

//*********************************

class Lake extends Pond {
        public void method3() {
            System.out.println("Lake 3");
            method2();
      }
}

//****************************
class Driver
{
public static void main(String[] args)
{
    
   Object var4 = new Bay(); 
   Lake var5 = new Bay();
    
  // the following lines of code are causing wither syntax or runtime error
    
   // var4.method2();  error 1
 
  // ((Ocean) var5).method1();  error 2

}
}

Answer the following question.

Don't use plagiarized sources. Get Your Custom Essay on
Consider the following code:
Just from $8 /Page 0r 300 words
Order Now

Identify the cause of the error is it run time error or syntax error.

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

Explain why the error is happening

provide code to fix the problem. Do not change the declaration or the instantiation to fix the issue.

 

In: Computer Science

Looking for a similar assignment? Get help from our qualified experts!

Order Now