Hello is this for java, i put in the code but i keep getting this error: 1 impor
ID: 3708919 • Letter: H
Question
Hello is this for java, i put in the code but i keep getting this error:
1 import java.util.Scanner; 3 public class UnitTesting f 4 II Method returns origNum cubed 5 public int cubeNum(int origNum) t return origNum origNum * origNum 9 public static void main (String args) f UnitTesting cubeTester new UnitTesting; System.out.println("Testing started") 13 System.out.println("2, expecting 8, got: cubeTester.cubeNum(2)); "+cubeNum(3)); System . out.println("?,expecting System.out.println("-1,expecting 15 27,got: -1,got: "+cubeNum(-1)); Your solution goes here*/ System.out.println("Testing completed") 18 19 20Explanation / Answer
Note:- In java from the methods declared as static we can only call the other static methods in the class and we cannot directly call the non static methods
So, to solve the error you are getting declare the method 'cubeNum' as static and the code will perfectly work fine
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.