The document contains an assignment on object oriented programming concepts with four questions. The first question explains the properties of constructors and how a superclass constructor can be called from a subclass constructor. The second question involves creating classes and objects to call methods. The third question explains the hierarchy of interfaces, abstract classes and classes in Java. The fourth question provides an incomplete class definition and asks to add a constructor, method, and code to create an object.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
63 views3 pages
OOPS Assignment 1 by Abhishek Aggarwal
The document contains an assignment on object oriented programming concepts with four questions. The first question explains the properties of constructors and how a superclass constructor can be called from a subclass constructor. The second question involves creating classes and objects to call methods. The third question explains the hierarchy of interfaces, abstract classes and classes in Java. The fourth question provides an incomplete class definition and asks to add a constructor, method, and code to create an object.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
School of Computer Science
UNIVERSITY OF PETROLEUM AND ENERGY STUDIES
DEHRADUN, UTTARAKHAND
Object Oriented Programming
(CSEG 2020)
Assignment 1 (2022-2023)
Submitted To: Submitted By:
Mr. Jitendra Rajpurohit Abhishek Aggarwal Associate Professor B. Tech. CSE CCVT School of Computer [3rd Semester] Science SAP ID: 500091436 Batch-[B1] SN Component Points CO 1 Explain the properties of constructors. Explain how a 3 2 constructor of the superclass can be called in a constructor of subclass. 2 Write a program to: 3 2 Create a class A with a method that displays “This is parent class method”. Create subclass B of class A with a method that displays “This is child class method”. Create an object of each class A and B and a) Call class A method for class A object b) Call class B method for class B object c) Call class A method for class B object
3 Explain the hierarchy of Interface, Abstract Class and Class in 4 3
java. Include when each of the three are applicable with respect to implementing methods. 4 Consider the following incomplete definition of a class 5 1 public class Day { private String name; private int day; private String month; // include your code here } a) Write a three-argument constructor which creates an object of the above class by setting the argument values to data members to the object. b) Write a method IsSameMonth() with Boolean return type which compares two objects and return TRUE if they have the same value for month. c) Write a piece of code to be included in main() to create an object with the attributes: name = “NewYear”; day = 1; month = “January” 1. A Constructor is a block of codes which is similar to the method. It is called when the instance of the class is created. Properties of the Constructor are: 1. The name of the constructor must be same as that of class. 2. It can have a parameter list. 3. It can be overloaded 4. No return type can be specified for it. 5. It is executed automatically when the object is created.