C Books Guide and List
C++ Books Guide and List
Best Java Books

3,749 questions

4,049 answers

114 comments

10,705 users

How to declare Class with one method?

0 votes
85 views
asked by augustaina Sr Member (4,820 points)

1 Answer

0 votes
public class MainClass
{
   public static void main( String args[] )
   {
      GradeBook myGradeBook = new GradeBook();

      myGradeBook.displayMessage();
   }
}
class GradeBook
{
   public void displayMessage()
   {
      System.out.println( "Welcome to the Grade Book!" );
   }
}
output
Welcome to the Grade Book!
it is an animal!
answered by sunny Expert (11,410 points)

Related questions

0 votes
1 answer 93 views
0 votes
1 answer 53 views
0 votes
1 answer 81 views
81 views asked by smith Geek (15,340 points)
0 votes
1 answer 81 views
0 votes
1 answer 82 views
...