abstract class:
An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.
Program Code:
Filename: TestCalendar.Java
//Import the packages
import java.util.*;
//class definition
public class TestCalendar
{
//main function definition
public static void main(String[] args)
{
/* Construct a Gregorian calendar for the current date and time*/
Calendar calendar = new GregorianCalendar();
//print current time by using object Calender
System.out.println("Current time is " + new Date());
System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
System.out.println("DATE: " + calendar.get(Calendar.DATE));
System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
System.out.println("HOUR_OF_DAY: " +
calendar.get(Calendar.HOUR_OF_DAY));
System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
System.out.println("SECOND: " + calendar.get(Calendar.SECOND));
//print the current day of the week
System.out.println("DAY_OF_WEEK: " calendar.get(Calendar.DAY_OF_WEEK));
//print the current day of the month
System.out.println("DAY_OF_MONTH: " +
calendar.get(Calendar.DAY_OF_MONTH));
//print the current day of the year
System.out.println("DAY_OF_YEAR: " +
calendar.get(Calendar.DAY_OF_YEAR));
//print the current week of the month
System.out.println("WEEK_OF_MONTH: " +
calendar.get(Calendar.WEEK_OF_MONTH));
//print the current week of the year
System.out.println("WEEK_OF_YEAR: " +
calendar.get(Calendar.WEEK_OF_YEAR));
//print whether time is in A.M or P.M.
System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
// Construct a calendar for December 25, 1997
Calendar calendar1 = new GregorianCalendar(1997, 11, 25);
String[] dayNameOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday"};
//print day of the week
System.out.println("December 25, 1997 is a " +
dayNameOfWeek[calendar1.get(Calendar.DAY_OF_WEEK) - 1]);
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (11th Edition)
- For this assignment you are tasked to list out the purposes of the AST and Evaluator classes.arrow_forwardIs it possible to modify the scope of the subclass's overridden method?arrow_forwardWrite in python and please include docstring. Write a class named Employee that has private data members for an employee's name, ID_number, salary, and email_address. It should have an init method that takes four values and uses them to initialize the data members. It should have get methods named get_name, get_ID_number, get_salary, and get_email_address. Write a separate function (not part of the Employee class) named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object. It should do the same with the second value of each list, etc. to the end of the lists. As it creates these objects, it should add them to a dictionary, where the key is the ID number and the value for that key is the whole Employee object. The function should return the resulting dictionary. For example, it…arrow_forward
- True or False? Interface can be used to store a common method implementation.arrow_forwardDifferentiate parameters passing method i.e, by line, by reference, by parameter? with suitable examples.arrow_forwardMust be written in Python. Please include docstring and show how output should look like. Remember that all data members should be private. An object can access it's own private data members directly. It can also access the private data members of other objects of the same class directly. But when accessing a private data member of an object of another class, it needs to call the appropriate get method. If that sounds complicated, just remember this: if a method is in the same class as a private data member, then it can access that data member directly, otherwise, it needs to use a get method. Write a class named Point that has two data members, x_coord and y_coord, representing the two coordinates of the point. It should have: an init method that takes two arguments, an x-coordinate and y-coordinate (in that order), and uses them to initialize the two data members. get methods for the two data members: get_x_coord and get_y_coord. a method named distance_to that takes a Point object…arrow_forward
- what is the generic term for a method that creates an instance of a class (constructors?) and how would you call it for a class named MyClass that does not take any parameters in PYTHON?arrow_forwardRequirement: In this assignment, you are going to build classes that handle bank accounts to support foreign currencies. In the attached files, there is a new class ForeignCurrencyAccount that extends the Account class that you developed in the previous assignment. Please complete the implementation of ForeignCurrencyAccount, because it only includes method headers, and TO DO comments for you to complete. You will use the Account class that you have developed earlier. Copy your version of Account.java to same src folder for Assignment #3. Add this method to Account class before you start: public double getBalanceInCAD() {return balance;} Also download Test2.java and Transaction.java to your project's src folder. Test2.java file is a test program that creates Account and ForeignCurrencyAccount objects with different currencies and makes some financial transactions on the accounts. Test2 class will display account information while doing transactions. Transaction class is used to buy /…arrow_forwardWhat is method overloading? Is it permissible to define two methods that have the same name but different parameter types? Is it permissible to define two methods in a class that have identical method names and parameter lists, but different return value types or different modifiers?arrow_forward
- What are the differences between the static method and instance method.arrow_forwardYou are in process of writing a class definition for the class Book. It has three data attributes: book_title, book_author, and book_publisher. The data attributes should be private. In Python, write a setter/mutator method and a getter/accessor method for book_title(only) that will be part of your class definition. Note: You do not need to write the entire class definition. Just the two methods mentioned.arrow_forwardCreate a deck of cards class. Internally, the deck of cards should use another class, a card class. Your requirements are: The Deck class should have a deal method to deal a single card from the deck After a card is dealt, it is removed from the deck. There should be a shuffle method which makes sure the deck of cards has all 52 cards and then rearranges them randomly. The Card class should have a suit (Hearts, Diamonds, Clubs, Spades) and a value (A,2,3,4,5,6,7,8,9,10,J,Q,K)arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education