Consider the code below. What is the output after it is run? String s1 = “yellow”; String s2 = “jackets”; s2 = s2.toUpperCase(); s1 = s2; s2 = s1 + s2.charAt(2); System.out.println(s2);
Author: Anonymous
Given the code, is Dummy checked or unchecked? Is Temp check…
Given the code, is Dummy checked or unchecked? Is Temp checked or unchecked? Dummy : [Item1] Temp : [Item2] class Dummy extends Exception { public Dummy(String msg) { super(msg); } } class Temp extends RuntimeException { public Temp(String msg) { super(msg); } }
████ ████ ████████ ████████ ████████████████…
████ ████ ████████ ████████ ██████████████████████ ██████████████████████ ████████████████████ ████████████████ ████████████ ██████ STAY DETERMINED!
Given the class below, correctly override Object’s equals me…
Given the class below, correctly override Object’s equals method in this class, ensuring that it compares the full state of the object (i.e. the values of all data fields).Include the method header, curly braces, and implementation in your response. public class Car { private boolean isElectric; private String modelName; /* assume a valid constructor exists */ /* YOUR equals METHOD HERE */} Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.
Write an equivalent lambda expression that implements the fu…
Write an equivalent lambda expression that implements the functional interface T1 that could be used to replace the anonymous inner class given below. An example inner anonymous class implementation is given below. The body of the implementation must match the implementation given. Note: you only need to write the lambda expression NOT the entire block of code below. public class Stardew { public static void main(String[] args) { Stardew myStardew = new Stardew (); myStardew.doStuff(new T1() { public double power(double base, double exp) { return Math.pow(base, exp); } }); } public void doStuff(T1 t1) { System.out.println(t1.power(2, 9)); } } interface T1 { public double power(double base, double exp); } Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.
Implement a class named QuestionBank that has two generic ty…
Implement a class named QuestionBank that has two generic types. The first generic type should be called S and the second generic type should be called T. Generic type S should ensure that the List interface has been implemented and parameterized for type S. This class should also contain a private field of type S named questions and a private field of type T named exam. No constructors or additional defining code is necessary. Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.
What is the result of the following boolean expression?…
What is the result of the following boolean expression? !((1 != 2) || (3 == 4))
Given the following code, what is the value of b? String s1…
Given the following code, what is the value of b? String s1 = “CLOWNSHOES”;String s2 = s1;s2.toLowerCase();boolean b = s1.equals(s2);
What makes the declared variable in the statement below a co…
What makes the declared variable in the statement below a constant? final int N = 3;
Given the code below, what will be the value returned from t…
Given the code below, what will be the value returned from the method invocation shown? public static int mystery(int a, int b) { if (a == 3 || b == 3) { return 1; } else { return b + mystery(a / 3, b * 2); }} int value = mystery(81, 2);