Answer 4:
True statements are:
1. Generic code only works with values of reference types.
3. Java will always add a default constructor to any class that you define.
5. Generic algorithms allow you to write code that can operate on argument of multiple different types.
7. A class called Pait<T, V> has two type parameters.
Explanation:
2. Autoboxing is when a reference type is automatically converted into the corresponding primitive type. - False because Autoboxing converts primitive types into wrapper objects and auto-unboxing takes place when an object is to be converted into a primitive type.
4. All exceptions in java implements the Throwable interface. - False because Throwable is a class that is extend.
6. The type wrapper for the int primitive type is called Int. - False because its Integer.
8. A float is a 64-bit floating point type. - False because it is a single-precision 32-bit IEEE 754 floating point.
Answer 5:
True statement is:
1. I/O streams are only useful for reading to/ writing from file on disk.
Explanation:
All other byte streams in Java are built on top of the basic InputStream and OutputStream . Reader , Writer. Abstract classes that define the basic functionality for reading or writing a sequence of character data, with support for Unicode. All other character streams in Java are built on top of Reader and Writer .
Please give thumbsup, if you like it. Thanks.
Which four of the following statements are true? Generic code only works with values of reference...
Which of the four are true? a). Generic code only works with values of reference types. b). Autoboxing is when a reference type is automatically converted into the corresponding primitive type. c). Java will always add a default constructor to any class that you define. d). All exceptions in Java implement the Throwable interface. e). Generic algorithms allow you to write code that can operate on arguments of multiple different types f). The type wrapper for the int primitive type...
I need help answering the following: Why does the following code not compile? List<Integer> intList = new ArrayList<>(); List<Number> numList = intList; a). The types list and ArrayList are different b). Integer is not a subclass of Number. c). List<Integer> is not a subclass of List<Number> d). There is a syntax error. Which of the following statements about Java I/O streams is true? a). I/O streams are only useful for reading to / writing from files on disk b). Character...
C++ programing
Which of the following statements (a-d) are true if the following lines of code are executed? int G = 17; int &H = G; A. H is now an alternate name for G B. Adding 1 to H will change the value of G to 18 C. Subtracting 5 from G and printing H will display the value 12 D. The condition H == G will give a true result E. All of the statements (a-d) are true...
This is a reminder that this is not a C++ or Java course. It is a Data Structures course. This means that you are to write your own code unless otherwise specified in the assignment. The use of built in data structures types like linked lists, stacks, queues, trees, maps, graphs etc. is prohibited and will result in a 60% reduction in your grade. Furthermore, the lecture material presents code that should be used to get you started. Any data...
Question 1 Consider the following code snippet: public class Box<E> { private E data; public Box() { . . . } public void insert(E value) { . . . } public E getData() { . . . } } What will result from executing the following code? Box<String> box = new Box<>(); . . . box.insert("blue Box"); String b = box.getData(); A. run-time error B. compiler warning C. no error D. compiler error Question 2 What is used as a...
use java and write in text
a. Rewrite the following code segment using if statements. Assume that grade has been declared as of type char. char grade= 'B';; switch (grade) { case 'A': System.out.println("Excellent"); break case 'B': System.out.println("Good"); default: System.out.println("you can do better”); } - b. write Java code that inputs an integer and prints each of its digit followed by ** e.gif the integer is 1234 then it should print 1**2**3**4 e.g. if the integer is 85 then it...
-------------------------------------------------------------------- 1. How does Java support the concept of encapsulation? -------------------------------------------------------------------- 2. Describe the difference between an object and a class. -------------------------------------------------------------------- 3. What is the difference between the contents of a Java variable of a primitive type and a Java variable of a class type? -------------------------------------------------------------------- 4. (a) How is a 'static' class method different from a regular (non-static) class method? (b) How is a 'static' variable in a class different from a regular (instance) variable in a class?...
Part Two: Fill in the Blanks and True/False (24 total points - 2 points each) For each of the following, fill in the most appropriate word(s)phrase/solution in each blank 1) Keywords, identifiers and literals are all kinds of are simply groups of characters that are used for various purposes in a program. , which 2) The Java expression: 11 - 2 + 3 evaluates to 3) List the Java boolean (logical) operators in order from highest priority to lowest priority...
Consider the following Java 8 code, and select true statements: public interface Functionlnterface1 void abstFun1 (int x) public interface Functioninterface2( void abstFun2(int x); public class Main implements Functioninterface2( @Override public void abstFun2(int x) System.out.printin(3'x); public static void main(Stringl args) ( Functioninterface1 fobj (int x)->System.out.printin(2"x) fobj.abstFun1(5); Main me - new Main; me.abstFun2(5); Functioninterface2 fobj2-(int x)->System.out.printin(4%; fobj2.abstFun2(5) 2 in main will not run because abstFun2 was previoudly implemented. O The fobj instance of Functionlnterface1 is created using the lambda at runtime without...
TASK: Which of the following statements about the Java HashMap are true? (Select all that apply) Select all correct options from the list If you try to store a key that’s already in a HashMap, the previous value associated with the key will be overwritten You cannot store duplicate values in a HashMap A HashMap can only use non-primitive types as keys A HashMap cannot have null as a key A HashMap can have multiple null keys A HashMap can...