Skip to main content

Posts

Featured

Task 03 - Constructors and Constructor Overloading

Task 03 - Constructors and Constructor Overloading | SOLVED BY M.SAAD Task Learning Objectives: Data encapsulation using get and set methods and how to protect from outside access. How to define one or more constructors in a Java class How to initialize fields at the time of object instantiation How to call a constructor from another constructor How to calculate a property is calculated at runtime, think of it like derived fields. Task 3.1 Create a Circle class such that it shall be mandatory for the user to pass the radius when its object is instantiated. Encapsulate radius field i.e. expose via getter and setter methods for public access to read and update. Make sure, its value is updated only when new value is greater than 0. Define  calculateArea  and  calculatePerimeter  methods with public access modifiers. Demonstrate the implemented functionality from main method of TestCircle class.

Latest Posts

Task 02 : Classes, Instance Attributes and Methods

Task 01 - Java Basics