JAVA PROGRAMMING
Lab Manual — Methods & Static Functions
Subject Static methods, parameters, return types, String methods, Scanner
Level Beginner to Intermediate
Tasks 6 Fully Solved Tasks with Corrected Code & Output
Concepts void methods, return values, String, Math, Scanner, method calls
Language Java
Format Study Reference / Lab Guide
Disclaimer: This document is intended as a study reference and learning guide only. All solutions are original
work. Please use responsibly for educational purposes.
Original Work | For Educational Use Only
, Java Programming Lab Manual — Methods & Static Functions Page 2 | Original Work | For Educational Use Only
Introduction to Java — Methods & Static Functions
This lab manual covers Java static methods — how to define them, pass parameters, return values, and call
them from main. You will practice void methods that print results directly, methods that return computed
values, methods that work with String objects, and methods with multiple parameters. Each task is fully
solved with corrected code, expected output, and step-by-step explanation.
Core Concepts at a Glance
Concept Syntax Purpose
void method public static void name(params){ } Performs action, returns nothing
return method public static int name(params){ return x; } Computes and returns a value
method call name(args); or int r = name(args); Executes the method
String param public static void name(String s){ } Pass text to a method
int param public static void name(int n){ } Pass number to a method
String.length() word.length() Number of characters in string
String.charAt(n) word.charAt(n) Character at position n (0-based)
type casting (int) seconds / 3600 Convert double to int
What You Will Learn
■ Write a void method that checks if a number is prime.
■ Write a void method that converts seconds to hours, minutes, seconds, and milliseconds.
■ Write a method that counts vowels and measures String length.
■ Write a method that calculates area and perimeter of a square or parallelogram.
■ Write a method that extracts first, last, and positional characters from a String.
■ Write a two-method program using getInput() and printInput() with parameter passing.
Original Work | For Educational Use Only