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
86 views
asked May 10, 2014 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 May 10, 2014 by smith Geek (15,340 points)

Related questions

0 votes
1 answer 80 views
80 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
0 votes
1 answer 16 views
16 views asked Apr 25, 2014 by taye Sr Member (4,970 points)
0 votes
1 answer 37 views
37 views asked May 11, 2014 by rock Expert (14,990 points)
0 votes
1 answer 51 views
51 views asked Apr 25, 2014 by taye Sr Member (4,970 points)
0 votes
2 answers 69 views
69 views asked May 10, 2014 by augustaina Sr Member (4,820 points)
...