Homework What are the differences between constructors and methods ? What is wrong with each of the following programs? 1: public class ShowErrors { 2:    public static void main ( String [] args ) { 3:       ShowErrors t = new ShowErrors( 5 ); 4:    } 5: } 1: public class ShowErrors { 2:    public static void main ( String [] args ) { 3:       ShowErrors t = new ShowErrors(); 4:       t.x(); 5:    } 6: } 1: public class ShowErrors { 2:    public void method1 () { 3:       Circle c; 4:       System.out.println( “What is radius ” 5:          + c.getRadius() ); 6:       c = new Circle(); 7:    } 8: } 1: public class ShowErrors {  2:    public static void main(String[] args) {  3:       C c = new C(5.0);  4:       System.out.println(c.value);  5:    }  6: }  7:   8: class C {  9:    int value = 2; 10: } Which of the following statements are valid? int i = new int(30); double d[] = new double[30]; char[] r = new char(1..30); int i[] = (3, 4, 3, 2); float f[] = {2.3, 4.5, 6.6}; char[] c = new char(); Given an array of double s, write Java statements to do the following: Assign the value 5.5 to the last element in the array. Display the sum of the first two elements of the array. Write a loop that computes the sum of all elements in the array. Write a loop that finds the minimum element in the array. Randomly generate an index and display the element of this index in the array. Use an array initializer to create another array with the initial value 3.5, 5.5, 4.52, and 5.6. Use the following illustration as an example, show how to apply the binary search approach to a search first for key 10 and then key 12, in the list: [2, 4, 7, 10, 11, 45, 50, 59, 60, 66, 69, 70, 79] . key is 11 0   1   2   3   4   5   6   7   8   9  10  11  12 11<50  [ 2,  4,  7, 10, 11, 45, 50, 59, 60, 66, 69, 70, 79]        low=0                   mid=6                   hi=12  11>7   [ 2,  4,  7, 10, 11, 45, 50, 59, 60, 66, 69, 70, 79]        low=0    mid=2      hi=5  11=11  [ 2,  4,  7, 10, 11, 45, 50, 59, 60, 66, 69, 70, 79]                    low=3    hi=5                        mid=4 (Note how binary search eliminates half of the list from further consideration after each comparison.) What types of array can be sorted using the Java.util.Arrays.sort method?  Does this sort method create a new array? Which of the following statements are valid? int[][] r = new int[2]; int[] x = new int[]; int[][] y = new int [3][]; int[][] z = {{1, 2}}; int[][] m = {{1, 2}, {2, 3}}; int[][] n = {{1, 2}, {2, 3}, }; Describe the difference between passing a parameter of a primitive type and passing a parameter of a reference type.  Then show the output of the following program: 1: class Test {  2:     public static void main ( String [] args ) {  3:         Count myCount = new Count();  4:         int times = 0;  5:         for ( int i = 0; i < 100; i++ )  6:             increment( myCount, times );  7:         System.out.println( "count is " + myCount.count );  8:         System.out.println( "times is " + times );  9:     } 10:     public static void increment ( Count c, int times ) { 11:         c.count++; 12:         times++; 13:     } 14: } 15:  16: class Count { 17:     public int count; 18:     public Count ( int c ) { 19:         count = c; 20:     } 21:     public Count () { 22:         count = 1; 23:     } 24: } What is wrong in the following code?1: public class Test { 2:    public static void main ( String [] args ) { 3:       java.util.Date[] dates = new java.util.Date[10]; 4:       System.out.println( dates[0] ); 5:       System.out.println( dates[0].toString() ); 6:    } 7: } If a class contains only private data fields and no “set” methods, is the class considered to be immutable ? If a class contains only data fields that are both private and primitive, and no “set” methods, is the class considered to be immutable ? What is wrong in the following code? 1: public class C {  2:     private int p;  3:   4:     public C () {  5:         System.out.pri...

Looking for solution of this Assignment?

WHY CHOOSE US?

We deliver quality original papers

Our experts write quality original papers using academic databases.We dont use AI in our work. We refund your money if AI is detected  

Free revisions

We offer our clients multiple free revisions just to ensure you get what you want.

Discounted prices

All our prices are discounted which makes it affordable to you. Use code FIRST15 to get your discount

100% originality

We deliver papers that are written from scratch to deliver 100% originality. Our papers are free from plagiarism and NO similarity.We have ZERO TOLERANCE TO USE OF AI

On-time delivery

We will deliver your paper on time even on short notice or  short deadline, overnight essay or even an urgent essay