O'Reilly logo

A Programmer’s Guide to Java™ SCJP Certification: A Comprehensive Primer, Third Edition by Rolf W. Rasmussen, Khalid A. Mughal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix E Solutions to Programming Exercises

1 Basics of Java Programming

1.1 The printStackElements() method of the PrintableCharStack class does not pop the elements.

//Filename: PrintableCharStack.javapublic class PrintableCharStack extends CharStack {                 // (1)  // Instance method  public void printStackElements() {                                // (2)    for (int i = 0; i <= topOfStack; i++)      System.out.print(stackArray[i]); // print each char on terminal    System.out.println();  }  // Constructor calls the constructor of the superclass explicitly.  PrintableCharStack(int capacity) { super(capacity); }             // (3)}//Filename: Client.javapublic class Client {  public static void main(String[] args) { ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required