Write, compile, and test a class that displays at least four lines of your favorite song.
Save the class as FavoriteSong.java.
public class FavouriteSong {
public static void main(String[] args) {
System.out.println("tere bin na lain gay ab kadam");
System.out.println("tere meri meri teri pram khani");
System.out.println("tu hi ha zingdi");
System.out.println("jag suna suna lagy");
}
}
Explanation
In this task, you will be writing a Java class that displays at least four lines of your favorite song. The objective is to familiarize yourself with the basics of Java programming and the process of writing, compiling, and testing code.
Here are the steps you’ll need to follow:
- Write the code: To write the class, you’ll need to open a text editor or an integrated development environment (IDE) such as Eclipse or IntelliJ IDEA. The class should include a method that displays the lyrics of your favorite song.
- Compile the code: After writing the code, you’ll need to compile it to check for any syntax errors. If the code compiles successfully, it will generate a .class file, which can then be executed.
- Test the code: Once the code is compiled, you can run it to see if it works as expected. You should see the lyrics of your favorite song displayed on the screen.
- Save the class: Finally, you’ll need to save the class as “FavoriteSong.java”. This is important because the file name should match the class name for the code to work properly.
By completing this task, you’ll have a basic understanding of Java programming and the process of writing, compiling, and testing code. You’ll also have a fun way to display the lyrics of your favorite song!
Leave a Reply