Category IS5103

IS5103 Week 2 Solutions

1. What is the output of the following code snippet? 1. int temperature = 4; 2. long humidity = -temperature + temperature * 3; 3. if (temperature>=4) 4. if (humidity < 6) System.out.println(“Too Low”); 5. else System.out.println(“Just Right”); 6. else System.out.println(“Too High”);  Just Right  2. What…

IS5103 Lesson-13

1.Assuming this class is accessed by only a single thread at a time, whatis the result of calling the countIceCreamFlavors() method?import java.util.stream.LongStream;public class Flavors {private static int counter;public static void countIceCreamFlavors() {counter = 0;Runnable task = () -> counter++;LongStream.range(0, 500).forEach(m…

IS5103 Lesson-12

1.Which of the following statements are true about a module containing afile named module-info.java? The content of the file is:module com.food.supplier {}Each correct answer represents a complete solution. Choose all that apply.A) No packages inside the module are automatically exported.…

IS5103 Lesson-11

1.Which statement about the following class is correct?class Problem extends Exception {public Problem() {}}class YesProblem extends Problem {}public class MyDatabase {public static void connectToDatabase() throw Problem {throws new YesProblem();}public static void main(String[] c) throw Exception {connectToDatabase();}}A) None of these 2.Which…

IS5103 Lesson 4 quiz

1. What is the output of the following code? public class Fish { The code does not compile. 2. What is the output of the following code?var numbers = “012345678”.indent(1);numbers = numbers.stripLeading();System.out.println(numbers.substring(1, 3));System.out.println(numbers.substring(7, 7));System.out.print(numbers.substring(7));Each correct answer represents a part of…

IS5103 Lesson-10

1.Which of the following throw an exception when an Optional is empty?Each correct answer represents a complete solution. Choose all that apply.A) opt.orElseThrow(); opt.orElseThrow(RuntimeException::new); opt.get(); 2.Assume that the directory /animals exists and is empty. What is theresult of executing the…

WEEK 1 LESSON 1 QUIZE

Q.1: Which of the following are legal entry point methods that can be run from  the command line?  A)   1. public final static void main(String[] args)  2. public static void main(String[] args)  Q.2: Given the following classes, which of the…

IS5103 WEEK 1 PreAssesment

1) Which of the following can fill in the blanks in order to make this code compile? __________ a = __________.getConnection(url, userName, password);__________ b =  a.prepareStatement(sql);__________ c = b.executeQuery();if (c.next())  System.out.println(c.getString(1));  Connection, DataSource, PreparedStatement, ResultSet 2) What is the output of…

IS5103 Lesson-9 Quiz

1.Suppose you need to display a collection of products for sale, whichmay contain duplicates. Additionally, you have a collection of sales thatyou need to track, sorted by the natural order of the sale ID, and youneed to retrieve the text…

IS5103 Week 1 Lesson 2 quiz

1. Which of the following operators are ranked in increasing or the same  order of precedence? Assume the + operator is binary addition, not the  unary form.  A).  1. +, *, %, —  2. =, ==, !  2. The _________…