0
why declare at class computer able to run no error but error when put below class laptop?
public class Computer { Computer (){ System.out.println("Constructor of Computer Class."); } void computer_method() { System.out.println("Power gone! Shut down your PC Soon......"); } Â Â public static void main(String[] args) { Â Â Computer my=new Computer(); Laptop your=new Laptop(); Â Â my.computer_method(); your.laptop_method(); } Â Â Â Â Â Â } class Laptop { Laptop(){ System.out.println("Constructor of laptop class"); } void laptop_method(){ System.out.println("9% Battery available."); }
4 Answers
+ 5
Your code is incomplete class computer is missing, First create a Class named Computer and put all this code inside that class.
+ 2
JavaScript is a different language
0
0_O-[MĂ€gĂĄr_SĂĄm_ĂkĂ _NĂŒllpÞïntĂȘr_ĂxĂ«cĂ©ptïön]~~ why declare at class computer able to run no error but error when put below class laptop?
0
Coding CAT thank you. i get that. but what i meant was, why the program cannot run when the "public static void main" was declare in the Laptop class? But it can run perfectly when it is declared under the Computer class.