1 / 9

بررسی چند نمونه سوال امتحانی

بررسی چند نمونه سوال امتحانی. درس برنامه سازی پیشرفته. مثال (1). خروجی قطعد کد زیر چیست ؟ for( int i=0 ;(i/2)<24;i ++){ switch(i%6){ case 0 : System.out.println ("Zero"); case 1 : System.out.println ("One"); i=i+1; break;

zihna
Download Presentation

بررسی چند نمونه سوال امتحانی

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. بررسی چند نمونه سوال امتحانی درس برنامه سازی پیشرفته

  2. مثال (1) خروجی قطعد کد زیر چیست ؟ for(int i=0 ;(i/2)<24;i++){ switch(i%6){ case 0 : System.out.println("Zero"); case 1 : System.out.println("One"); i=i+1; break; case 2 : System.out.println("Two"); i*=2; case 3 : System.out.println("Three"); i*=3; break; case 4 : System.out.println("Default"); } } Zero One Two Three One Three Default Abdolmaleki.s@gmail.com

  3. مثال (2) خروجی قطعد کد زیر چیست ؟ int a=12,b=9; int c=(a&b)>>2; System.out.println(c); 2 Abdolmaleki.s@gmail.com

  4. مثال (3) خروجی قطعه کد زیر چیست ؟ intk=0,j=1; boolean b; b=(k++ == j) && (k==++j); System.out.println("b= "+b+" k= "+k+" j= "+j); b= false k= 1 j= 1 Abdolmaleki.s@gmail.com

  5. مثال (4) خروجی قطعه کد زیر چیست ؟ int k=0,j=0; boolean b; b=(k++ == j) || (k==++j); System.out.println("b= "+b+" k= "+k+" j= "+j); b= true k= 1 j= 0 Abdolmaleki.s@gmail.com

  6. مثال (5) با استفاده از مفهوم Composition کلاسRoom و Wall و Window و Handle را با شرایط زیر طراحی کنید. هر اتاق دارای 4 دیوار و هر دیوار دارای یک پنجره و هر پنجره دارای دو دستگیره با نام های left و right است و هر دستگیره دارای متد openبرای باز کردن و متد Close برای بستن می باشد. راهنمایی :اگر r یک شی از کلاس Room باشد ، برای باز کردن پنجره دیوار اول با استفاده از دستگیره چپ به شکل زیر عمل می شود r.w[0].win.left.open() Abdolmaleki.s@gmail.com

  7. Passing Classes to Methods class Letter { char c; } public class PassObject { static void f(Letter y) { y.c = 'z'; } public static void main(String[] args) { Letter x = new Letter(); x.c = 'a'; System.out.println("1: x.c: " + x.c); // Prints 1: x.c: a f(x); System.out.println("2: x.c: " + x.c); // Prints 2: x.c: z } }

  8. Passing Primitives to Methods class Letter { char c; } public class PassPrimitive { static void f(char y) { y = 'z'; } public static void main(String[] args) { Letter x = new Letter(); x.c = 'a'; System.out.println("1: x.c: " + x.c); // Prints 1: x.c: a f(x.c); System.out.println("2: x.c: " + x.c); // Prints 2: x.c: a } }

  9. Good Luck!

More Related