Posts

Showing posts from July, 2024

P.MANIKANDAN,P23CS383

Image
 import java.io.*; import java.nio.file.*; import java.util.List; import java.util.stream.Collectors; public class AFO{     // Read file content     public static void readFile(String filePath) throws IOException {         List<String> lines = Files.readAllLines(Paths.get(filePath));         for (String line : lines) {             System.out.println(line);         }     }     // Write content to a file     public static void writeFile(String filePath, String content) throws IOException {         Files.write(Paths.get(filePath), content.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.APPEND);     }     // Copy a file     public static void copyFile(String sourcePath, String destinationPath) throws IOException {         Files.copy(Paths.get(sourcePath), Paths.ge...

Java quiz program

 import java.util.Scanner; class Questions {     public String[][] qpa;      public String[][] qca;      Questions() {         qpa = new String[10][5];         // questions and objectives         qpa[0][0] = "Which keyword is used to define a class in Java?";         qpa[0][1] = "1. define";         qpa[0][2] = "2. class";         qpa[0][3] = "3. Class";         qpa[0][4] = "4. def";         qpa[1][0] = "Which method is the entry point of a Java program?";         qpa[1][1] = "1. start()";         qpa[1][2] = "2. main()";         qpa[1][3] = "3. init()";         qpa[1][4] = "4. run()";         qpa[2][0] = "Which package contains the Random class?";         qpa[2][1] =...