PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Software Engineering Fundamentals/Walmart Labs

Implement a Shape interface using OOP

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's competency in object-oriented design and implementation, covering concepts such as interfaces, encapsulation, polymorphism, input validation, and immutability.

  • medium
  • Walmart Labs
  • Software Engineering Fundamentals
  • Software Engineer

Implement a Shape interface using OOP

Company: Walmart Labs

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

## Problem You are given the following interface (language-agnostic): ```text interface Shape { double area(); double perimeter(); } ``` Design and implement concrete classes for common shapes (at minimum): - `Circle(radius)` - `Rectangle(width, height)` Optionally add one more shape (e.g., `Triangle(a,b,c)` or `Square(side)`). ### Requirements - Use OOP best practices (encapsulation, clear naming, polymorphism). - Validate inputs (e.g., non-negative dimensions; for triangle, triangle inequality). - Make objects safe to use (e.g., immutable fields if possible). - Provide a small example showing how a caller can compute total area/perimeter of a list of `Shape` objects. ## What to submit - Class definitions + brief demonstration code (no need for UI).

Quick Answer: This question evaluates a candidate's competency in object-oriented design and implementation, covering concepts such as interfaces, encapsulation, polymorphism, input validation, and immutability.

Related Interview Questions

  • Answer Spring Boot and Thymeleaf engineering questions - Walmart Labs (medium)
Walmart Labs logo
Walmart Labs
Mar 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Software Engineering Fundamentals
1
0
Loading...

Problem

You are given the following interface (language-agnostic):

interface Shape {
  double area();
  double perimeter();
}

Design and implement concrete classes for common shapes (at minimum):

  • Circle(radius)
  • Rectangle(width, height)

Optionally add one more shape (e.g., Triangle(a,b,c) or Square(side)).

Requirements

  • Use OOP best practices (encapsulation, clear naming, polymorphism).
  • Validate inputs (e.g., non-negative dimensions; for triangle, triangle inequality).
  • Make objects safe to use (e.g., immutable fields if possible).
  • Provide a small example showing how a caller can compute total area/perimeter of a list of Shape objects.

What to submit

  • Class definitions + brief demonstration code (no need for UI).

Solution

Show

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Walmart Labs•More Software Engineer•Walmart Labs Software Engineer•Walmart Labs Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.