Class Photo Album Learn programming Java


OOP Object Oriented Programming


Class Photo Album


Create a class "PhotoAlbum" with a private attribute "numberOfPages."

It should also have a public method "GetNumberOfPages", which will return the number of pages.

The default constructor will create an album with 16 pages. There will be an additional constructor, with which we can specify the number of pages we want in the album.

Create a class "BigPhotoAlbum" whose constructor will create an album with 64 pages.

Create a test class "AlbumTest" to create an album with its default constructor, one with 24 pages, a "BigPhotoAlbum" and show the number of pages that the three albums have.


package December_19th__b_;
public class BigPhotoAlbum extends PhotoAlbum
	public BigPhotoAlbum()
		numberOfPages = 64;

package December_19th__b_;
import java.util.*;
public class Main
	public static void main(String[] args)
		boolean debug = false;

		//Create an album with its default constructor
		PhotoAlbum myAlbum1 = new PhotoAlbum();

		//Create an album with 24 pages
		PhotoAlbum myAlbum2 = new PhotoAlbum(24);

		//Create an BigPhotoAlbum 
		BigPhotoAlbum myBigPhotoAlbum1 = new BigPhotoAlbum();

		if (debug)
			new Scanner(;

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.