Ex63 Given class X static void mint i i0 7 public static void main String args

Ex63 given class x static void mint i i0 7 public

This preview shows page 40 - 46 out of 82 pages.

Ex.63Given:class X{static void m(int[] i ){i[0] += 7;}public static void main (String [] args){int[] j = new int[1];j[0] = 12 ;m(j) ;System.out.println(j[0]) ;}}What is the result? A. 7B. 12C. 19D.Compilation failsE.An exception is thrown at run tiomeAns: C Ex.64Which two statements are true?
Image of page 40
EEx.65Given:class Overloading{int x(double d){System.out.println(“one”) ;return 0 ;}String x(double d ){System.out.println(“two”) ;return null ;}double x(double d ){System.out.println(“three”) ;return 0.0 ;}public static void main(String[] args){new Overloading( ).x(4.0) }}What is the result? Ex.66The ctach clause argument is always of type_______.
Image of page 41
EX.67Given the code fragment:ArrayList<Integer>list = new ArrayList<>(1) ;list.add(1001) ;list.add(1002);System.out.println(List.get(list.size( ))) ;What is th result? A.Compilation fails due to an error on line 11.B.An exception is thrown at run time due to error on line 13C.An exception is thrown at run time due to error on line 14D.1002Ans: CEx.68View the Exhibitpublic class Hat{public int ID = 0 ;public String name = “Hat” ;public String size = “One Size Fit All” ;public String color = “ ”;public String getName( ){return name ;}public void setName(String name){this.name = name ;}}Given:public class TestHat{
Image of page 42
public static void main(String[ ] args){Hat blackCowboyHat = new Hat( ) ;}}Which statement sets the name of the Hat instance?
Image of page 43
doMoreStuff( );System.out.print(“3 ”) ;}public static void doMoreStuff( ) {System.out.print(“4”) }}Which two are possiblie outputs? Ex.70Given:public class MyFor{public static void main(String [] args){for (int ii = 0 ; ii < 4 ; ii++ ){System.out.print(“ii = ”+ ii);ii = ii + 1 ;}}}What is the result?
Image of page 44
Image of page 45
Image of page 46

You've reached the end of your free preview.

Want to read all 82 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture