Each class declaration that begins with keyword public must e stored in a file that has the same name as the class and ends with the .java file extension.
Thus, classes GradeBook and GradeBookTest must be declared in separate files, because each class is declared public.
**Declaring more than one public class in the same file is a compilation error!!
***We will use an example that consists of classes GradeBook (fig 3.1) and GradeBookTest (Fig 3.2). Class GradeBook (declared in GradeBook.java) will be used to display a message on the screen, welcoming the instructor to the grade book application. Class GradeBookTest (declared in file GradeBookTest.java) is an application class in which the main method will use an object of class GradeBook.
Each class declaration that begins with keyword public must e stored in a file that has the same name as the class and ends with the .java file extension.
ReplyDeleteThus, classes GradeBook and GradeBookTest must be declared in separate files, because each class is declared public.
**Declaring more than one public class in the same file is a compilation error!!
***We will use an example that consists of classes GradeBook (fig 3.1) and GradeBookTest (Fig 3.2). Class GradeBook (declared in GradeBook.java) will be used to display a message on the screen, welcoming the instructor to the grade book application. Class GradeBookTest (declared in file GradeBookTest.java) is an application class in which the main method will use an object of class GradeBook.