โ Back to Encapsulation
Question 459
Expression-Bodied Property
Expression-Bodied Property
Create a classRectanglewhose constructor stores aprivate int widthandheight. Add an expression-bodied read-only propertyArea(using=>) that returnswidth * height. Do not write aMainmethod. Fornew Rectangle(3, 4)the program prints: 12
Expected Output:
12
Topics:
Encapsulation
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.