QuestionDemo1.java.html

  1  import java.util.Scanner;
  2  
  3  /**
  4     This program shows a simple quiz with one question.
  5  */
  6  public class QuestionDemo1
  7  {
  8     public static void main(String[] args)
  9     {
 10        Scanner in = new Scanner(System.in);
 11  
 12        Question q = new Question();
 13        q.setText("Who was the inventor of Java?");
 14        q.setAnswer("James Gosling");      
 15  
 16        q.display();
 17        System.out.print("Your answer: ");
 18        String response = in.nextLine();
 19        System.out.println(q.checkAnswer(response));
 20     }
 21  }
 22