012-002-006

static Modifier: Using Class Methods

Medium

Problem Description

static Modifier: Using class Methods

In this problem, you will create a program that implements a static method max(int, int) in a MathUtil class, calls it directly using the class name without creating an instance, and displays the maximum of two integers read from standard input.

Learning Objective: Understand characteristics of static methods and implement utility methods callable without instances

Overview

Create a MathUtil class and implement a static method that returns the maximum of two integers. Call the method directly from the class name without creating an instance.

Specifications

  • MathUtil class static method max(int, int): Returns larger of two integers
  • In main method, read two integers using Scanner, call MathUtil.max(), and output result
  • No instance creation required

Input Format

integer a
integer b

Output Format

Max value: [maximum value]

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up