Programming Java

Tasks studies - laboratory


Project maintained by dawidolko Hosted on GitHub Pages — Theme by dawidolko

Lab06 - Static Class Members in Java

Task 0. Brief Introduction

Class members can be static or non-static.
Non-static members are always associated with the existence of an object (fields correspond to object elements, methods must be called on an object, and are messages to the object).
Static members (fields and methods) are shared across all objects and:

Note: Static methods must not reference non-static members of the class (as the object may not exist). However, they can refer to other static members.
Outside the class, static members can be accessed in two ways:

Task 1.

Create a class Figury. Add the following code to it and test its functionality. Note that the static methods PoleKola and ObwodKola use other static methods from the Math library, which is also a class. Add additional static methods inside the class to calculate the following shapes: square, rectangle, cone, cylinder.


cmd_gcc

Task 2.

Test and describe the functionality of the following source code.


cmd_gcc

Task 3.

Create a class Complex implementing the structure of complex numbers. Add the following static methods to the class for operations on complex numbers:

Also, add methods that return the value of a complex number as a string (String) in the following formats: