Compile and Execute Java Programs
Compile and Execute Java Programs
java
2. Lincoln3.java
//********************************************************************
//
//********************************************************************
public class
Lincoln3
{
public
static
void
main
String
[]
args )
System.out.println (
; System.out.println
}
3. Abstract about yourself
// Constructor
public Person(String name, int age) {
this.name = name;
this.age = age;
}
// Getter methods
public String getName() {
return name;
}
// Constructor
public Student(String name, int age, String studentId) {
super(name, age);
this.studentId = studentId;
}
// Constructor
public Teacher(String name, int age, String employeeId) {
super(name, age);
this.employeeId = employeeId;
}
// Example usage
public class Main {
public static void main(String[] args) {
// Creating instances of the concrete classes
Student student = new Student("Ignatius", 19, "2022390013");
Teacher teacher = new Teacher("Wahid", 29, "123456");
// Main class
public class GFG {
// Columnar printing
int n;
// Outer loop 1
// Prints the first half diamond
do {
n = 1;
// Inner loop 1
// Prints space until ++n <= number - m + 1 is
// false
do {
// Print whitespace between
System.out.print(" ");
// Inner loop 2
// Prints star until ++n <= m * 2 - 1 is false
do {
// Print star
System.out.print("*");
}
// Outer loop 2
// Prints the second half diamond
do {
n = 1;
// Inner loop 1
// Prints space until ++n <= number - m + 1 is
// false
do {
// Print whitespace between
System.out.print(" ");
// Inner loop 2
// Prints star until ++n <= m * 2 - 1 is false
do {
// Prints star
System.out.print("*");
int blockSize = 5;
createBlockLetter(initial, blockSize);
// Define the patterns for each letter (you can extend this for more letters)
String[] blockPatterns = {
" # # ",
"# #",
"# #",
"# #",
" # # ",
};
// Get the index for the given initial (assuming A-Z for simplicity)
int index = initial - 'A';
System.out.print(blockPatterns[index].charAt(i));
System.out.println();
} else {