Does the following code will compile if both classes are declared in

public class Car{
    public String myCar = "Ferrari" ;
public class Test{
    public static void main(String ... args){
        Car myCar = new Car();
Code will not compile because of the class Car. Only one of the classes in the file can be declared as public.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes