1 / 2

Drill – What does this program output?

Drill – What does this program output?. class Num { private int n; Num ( int num ) {set( num );} public int get (){return n;} public void set ( int num ){n= num ;} } class CB { public static void change( int a, int b, int c, Num d, Num e, int [] f, int [] g){

alyn
Download Presentation

Drill – What does this program output?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Drill – What does this program output? class Num { private int n; Num(intnum) {set(num);} public int get (){return n;} public void set (intnum){n=num;} } class CB { public static void change(int a, int b, int c, Num d, Num e, int[] f, int[] g){ b=d.get(); f[2]=a; g=f; d=e; e.set(c); c=9;} public static void main(String[] s){ int[] ia = {4,2,7}; int[] ib = {3,8,5}; Num n1=new Num(6); Num n2=new Num(1); change(ia[0],ia[1],0,n1,n2,ia,ib); for (int i=0;i<3;i++) System.out.println(ia[i]+" "+ib[i]); System.out.println(n1.get()+" "+n2.get());}}

  2. Answers (notes)

More Related