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)
- Must 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_forwardAssume B is a subclass of A. Which of the statements about the following assignment is false? A a = new B(); We can assign anything to variable a that has a subtype of B. We can call on a any method defined in A. We can call on a any method defined in B. We can assign anything to variable a that has a subtype of A.arrow_forwardTrue or False? Interface can be used to store a common method implementation.arrow_forward
- Write a Java application for the Banking system that consists of at least three classes for Bank, Clients and Transactions. The following concepts should be applied: Defining a constructor with and without arguments. Use the setter, getter and toString methods. Sending an object/s to a method and returning it as a return value. Defining array of objects and using loop/s and Scanner object/s for data entry. Defining the main method that integrates the whole project.arrow_forwardSELECT ALL the members of the class that are accessible via a static method in the supplied class below. Take note: In your response, leave off the constructor(s).arrow_forwardI'm learning java in college and I missed one homework assignment. Since then it has been difficult to keep up with homework because they were based on the one I missed. Here's the prompt: Design a class Phone with one data member as long phoneNumber. Add constructors, get/set methods to class Phone. Then design a class InternationalPhone as subclass of class Phone, with one extra data member as int countryCode. Add constructors, get/set methods to class InternationalPhone. Write a main program to test these two classes. (We use netbeans btw) I can't get any credit for this so there's no rush but I would be very happy to recieve an answer before the end of the semester. Thank you in advance :)arrow_forward
- Differentiate parameters passing method i.e, by line, by reference, by parameter? with suitable examples.arrow_forwardA. Writing an Interface In this problem you will first write an interface and then modify classes to implement the interface. Write an interface, GeometricSolid, which has one method, volume. The volume method takes no arguments and returns a double. You are provided with three classes: Cylinder, Sphere, and RightCircularCone Modify the classes so that they implement the GeometricSolid interface. Supply the appropriate method for each class. You can use Google search to find the formula for the volume. Make sure that you use Math.PI in your calculations. Notice in InterfaceRunner that the objects are added to an ArrayList of GeometricSolids. since I couldn't fit all images with two screen shots I left the link here link: https://codecheck.it/files/18040616319p6jy6gzkdzuq08nmlp81251tarrow_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
- Can you predict what type some of the Book class's fields are based on the constructor parameters? Can you make any educated guesses concerning the names of its fields?arrow_forwardUsing python: Suppose a call center has three levels of employees—respondent, manager, and director. An incoming telephone call must first be allocated to a respondent who is free. If the respondent cannot handle the call, the call must be escalated to a manager. If the manager is occupied, then the call should be escalated to a director. Design YOUR OWN classes and data structures for this problem. Implement a method dispatchCall() that assigns a call to the first available employee.arrow_forwardNot all dogs like to bark, but some like to make a lot of noise! In this exercise we have a Dog superclass and a LoudDog subclass. You do not need to modify the Dog class. Your task is to write two override methods in the LoudDog class. You will override the speak method to return BARK!. You will then override the toString so that it returns Clover is loud and likes to BARK! where Clover is replaced by the name variable. Create and print at least one Dog and one LoudDog to test. public class DogTester{public static void main(String[] args){// Start here}} public class Dog{private String name;public Dog(String name){this.name = name;}public String getName(){return name;}public String speak(){return "Bark!";}public String toString(){return name + " likes to " + speak();}} public class LoudDog extends Dog{public LoudDog(String name){super(name);}// Override the speak method here//Override the toString here.//Remember, you can access the name using super.getName()}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