Question 3 Analyze the code below Identify all of the illega

Question 3 Analyze the code below. Identify all of the illegal method calls and assignment statements. In your own words, in a sentence or two, for each illegal call or assignment, explain why it is illegal. You are welcome to compile this file to see what the compiler answer is. You may also go and research the compiler errors. You might also want to read up on static, private, and public in Java. Ultimately, however, you must explain in your own words why you are getting that error. Some answers will be the same for different statements file: 3. java public class A3 public static int u; private static int v; public int x; private int y; public void foo tt public static void far private void fazo private static void fiz public void test1 v 2; x 3; foo far faz()

Solution

First thing i have observed that as you are using the public static void test2() inside this getting compilation error on x,y , foo() and faz() because of you can not call or declare non-static mehtod or function and variable in static method or function.

To remove the error please make it either method not static or make it x,y , foo() and faz() static.

below is the correct code

-------------------

public class A3 {

   public static int u;
  
   private static int v;
  
   private static int x;
  
   private static int y;
  
   public static void foo(){}
  
   public static void far(){}
  
   private static void faz(){}
  
   private static void fiz(){}
  
   public void test1(){
      
       u=1;
      
       v=2;
      
       x=3;
       y=4;
      
      
       foo();
      
       far();
       faz();
       fiz();
   }
  
  
public static void test2(){
      
       u=5;
      
       v=6;
      
       x=7;
       y=8;
      
      
       foo();
      
       far();
       faz();
       fiz();
   }-------------------

Please paste the code on tool and see you will not get any compiler error.

 Question 3 Analyze the code below. Identify all of the illegal method calls and assignment statements. In your own words, in a sentence or two, for each illega
 Question 3 Analyze the code below. Identify all of the illegal method calls and assignment statements. In your own words, in a sentence or two, for each illega

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site