Three Layer Architecture Example

This program demonstrates layered architecture.

Problem Statement

Write a Java program with presentation, business, and data layers.

Source Code

1 class DataLayer {
2 String getData(){ return "Data from DB"; }
3 }
4 class BusinessLayer {
5 DataLayer dl=new DataLayer();
6 String process(){ return "Processed: "+dl.getData(); }
7 }
8 class PresentationLayer {
9 BusinessLayer bl=new BusinessLayer();
10 void show(){ System.out.println(bl.process()); }
11 }
12 public class LayeredArchitecture {
13 public static void main(String[] args) {
14 System.out.println("Eduinq Layered Architecture");
15 PresentationLayer pl=new PresentationLayer();
16 pl.show();
17 }
18 }

Program Output

Eduinq Layered Architecture
Processed: Data from DB

Explanation

Layers separate responsibilities. - Presentation interacts with Business, which interacts with Data. - This improves modularity and scalability in large systems. Conclusion: Shows layered architecture in practice.

Quick Links to Explore