Category IS5103

LESSON 7 AND 8 LABS

Lesson – 7 Labs 1. interface Shape{     public void draw(); } class Circle implements Shape{     public void draw(){         System.out.println(“Drawing a circle”);     } } class Square implements Shape{     public void draw(){         System.out.println(“Drawing a square”);     } } public class Demo{     public static…

IS5103 WEEK 4 QUIZ

1. What is the result of the following code? 1. interface Climb { 2. boolean isTooHigh(int height, int limit); 3. } 4. 5. public class Climber { 6. public static void main(String[] args) { 7. check((h, m) -> h.append(m).isEmpty(), 5); 8. } 9. private static void check(Climb climb, int…

IS5103 WEEK4 LESSON 7 QUIZ

1. Which of the following statements can be inserted in the blank line sothat the code will compile successfully? interface CanHop {}public class Frog implements CanHop {public static void main(String[] args) {_ frog = new TurtleFrog();}}class BrazilianHornedFrog extends Frog {}class…

IS5103 WEEK5 LAB SOLUTIONS

Lesson – 9 1. import java.util.*; import java.util.ArrayList;  import java.util.Collection;  public class Demo{      public static void main(String[] args){          Collection<String> city = new ArrayList<>();         city.add(“Chicago”);         city.add(“Boston”);         city.add(“Austin”);         city.add(“Seattle”);         city.add(“Nashville”);         city.remove(“Austin”); city.remove(“Chicago”); System.out.print(city);    …

IS5103 WEEK 3 QUIZ

Lesson-5      public int add(int x, int y){     int sum = x + y;     return sum; }     public static void main(String args[]){         Addition obj = new Addition();         int sum = obj.add(10, 20);         System.out.println(“The sum of 10 and 20 is ” +…

IS5103 Post Assessment

1.How many of the following lines contain a compiler error?long min1 = 123.0, max1 = 987L;final long min2 = 1_2_3, max2 = 9 _ 8 _ 7;long min3 = 123, int max3 = 987;long min4 = 123L, max4 = 987;long…

IS5103 Week 3 Solutions

1. Which of the following can fill in the blank in this code to make it  compile?  public class Ant {  _______ void method() {}  }  Each correct answer represents a complete solution. Choose all that apply.  A) Final Private  2. Which…

IS5103 Lesson-15

1.Which is the first line containing a compiler error?String url = “jdbc:hsqldb:file:zoo”;try (var conn = DriverManager.getConnection(url);var ps = conn.prepareStatement();var rs = ps.executeQuery(“SELECT * FROM swings”)) {while (rs.next()) {System.out.println(rs.getInteger(1));}}A) Line 3 2.Which interfaces or classes are in a database-specific JAR file?Each…

IS5103 Week 2 Quiz

import java.io.*; import java.util.*; public class Test{     public static void main(String[] args){         Scanner in = new Scanner(System.in);         String string1,string2;         string1 = in.nextLine();         string2 = in.nextLine();         if(string1.equals(string2))     System.out.println(“The two strings are equal.”); else     System.out.println(“The two strings are not equal.”);     } }…

IS5103 Lesson-14

1.Which of the following correctly create Path instances?Each correct answer represents a complete solution. Choose all that apply.A) FileSystems.getDefault().getPath(“puma.txt”) new java.io.File(“tiger.txt”).toPath() Path.of(Path.of(“.”).toUri()) 2.Suppose that the working directory is /weather and the absolute path represents a file that exists within the…