018-003-001
Generic Card Holder
Easy
Problem Description
In this problem, you will implement the displayInfo() method in the CardHolder class that returns a string in the format 'Card #[cardNumber]: [holderName]'.
Create a generic CardHolder class that can hold any type of card. It should have int cardNumber and String holderName fields, and a displayInfo() method that returns 'Card #[cardNumber]: [holderName]'.
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
new CardHolder<>(12345, "Tanaka"); holder.displayInfo()
Expected Output:
Card #12345: Tanaka
Normal case
Input:
new CardHolder<>(99, "Suzuki"); holder.displayInfo()
Expected Output:
Card #99: Suzuki
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 10 free executions remaining
