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 a method that has a parameter?

0 votes
93 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(); 
 
      String courseName = "Java ";
      myGradeBook.displayMessage( courseName );
   }
 
}
 
class GradeBook
{
   public void displayMessage( String courseName )
   {
      System.out.printf( "Welcome to the grade book for\n%s!\n", 
         courseName );
   }
 
}
 
output
Welcome to the grade book for
Java !
 
answered by smith Geek (15,340 points)

Related questions

0 votes
1 answer 85 views
85 views asked by augustaina Sr Member (4,820 points)
0 votes
1 answer 19 views
19 views asked by taye Sr Member (4,970 points)
0 votes
1 answer 41 views
41 views asked by rock Expert (14,990 points)
0 votes
1 answer 52 views
52 views asked by taye Sr Member (4,970 points)
0 votes
2 answers 76 views
76 views asked by augustaina Sr Member (4,820 points)
...