Java学習教材

Similar documents
Java学習教材

Javaプログラムの実行手順

K227 Java 2

8 if switch for while do while 2

10K pdf

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

解きながら学ぶJava入門編

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

新・明解Java入門

Java演習(4) -- 変数と型 --

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

Java updated

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

2

Microsoft Word - keisankigairon.ch doc

break 文 switch ブロック内の実行中の処理を強制的に終了し ブロックから抜けます switch(i) 強制終了 ソースコード例ソースファイル名 :Sample7_1.java // 入力値の判定 import java.io.*; class Sample7_1 public stati

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 条件判断文 3 switch 文 switch 文式が case の値と一致した場合 そこから直後の break; までを処理し どれにも一致しない場合 default; から直後の break; までを処理する 但し 式や値 1

I java A

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

r3.dvi

ALG ppt

Java 基礎問題ドリル ~ メソッドを理解する ~ 次のプログラムコードに 各設問の条件にあうメソッドを追加しなさい その後 そのメソッドが正しく動作することを検証するためのプログラムコードを main メソッドの中に追加しなさい public class Practice { // ここに各設問

untitled

JavaプログラミングⅠ

(Eclipse\202\305\212w\202\324Java2\215\374.pdf)

2

明解Javaによるアルゴリズムとデータ構造

2

(Basic Theory of Information Processing) 1

2

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

text_08.dvi

I. (i) Java? (A). 2Apples (B). Vitamin-C (C). Peach21 (D). Pine_Apple (ii) Java? (A). Java (B). Java (C). Java (D). JavaScript Java JavaScript Java (i

Javaセキュアコーディングセミナー2013東京第1回 演習の解説

: : : TSTank 2

Java講座

アルゴリズムとデータ構造1

JavaプログラミングⅠ


JavaプログラミングⅠ

ALG ppt

プログラミング入門1

問題1 以下に示すプログラムは、次の処理をするプログラムである

r6.dvi

Thread

JavaプログラミングⅠ

Microsoft PowerPoint ppt

r3.dvi

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2

10/8 Finder,, 1 1. Finder MAC OS X 2. ( ) MAC OS X Java ( ) 3. MAC OS X Java ( ) / 10

2 1 Web Java Android Java 1.2 6) Java Java 7) 6) Java Java (Swing, JavaFX) (JDBC) 7) OS 1.3 Java Java

10K

r2.dvi

extends (*) (*) extend extends 2

Java演習(2) -- 簡単なプログラム --

I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi

2 static final int DO NOTHING ON CLOSE static final int HIDE ON CLOSE static final int DISPOSE ON CLOSE static final int EXIT ON CLOSE void setvisible

Java (7) Lesson = (1) 1 m 3 /s m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac

untitled

新・明解Javaで学ぶアルゴリズムとデータ構造

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

r1.dvi

PowerPoint プレゼンテーション

アルゴリズムとデータ構造1

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A

untitled

JavaプログラミングⅠ

オブジェクト脳のつくり方

5

r2.dvi

問題1 以下に示すプログラムは、次の処理をするプログラムである

1.1 (1) (2) (3) (4) 2

class TestPrimitiveType{ public static

ALG ppt

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C

2.2 Java C main Java main 2 C 6 C Java 3 C Java ( ) G101Hello.java G101Hello main G101Hello.java /* G101Hello */ class G101Hello { /* main */ public s

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

ALG2012-F.ppt

presen.gby

ALG2012-C.ppt

I. java.awt.rectangle java.lang.math random Java TM API java.awt Rectangle Rectangle (x,y)... public int x Rectangle X public int y Rectangle Y public

cpp4.dvi

Assignment_.java 0 Assignment_.java 課題 : 台形の面積 / class Assignment_ public static void main(string[] args) throws IOException キーボード準備 int top, bottom,

Java演習(9) -- クラスとメソッド --

DVIOUT-exer

コーディング基準.PDF

明解Java入門編

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

r02.dvi

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

ALG2012-A.ppt

Transcription:

Java 2016/4/17

Java 1 Java1 : 280 : (2010/1/29) ISBN-10: 4798120987 ISBN-13: 978-4798120980 2010/1/29

1 Java

1 Java

Java Java class FirstExample { public static void main(string[] args) { System.out.println(" ");

Java

Java Java Windows MacOS Linux OS

C/C++ 1/2 B (#include # #if #ifdef ) C/C++

C/C++ 2/2 B boolean true/false new int[] a = new int[5]; String String str = "Hello"; C/C++

Java class { public static void main(string[] args) { Example public static void main(string[] args) { {

Java class FirstExample { public static void main(string[] args) { System.out.println(" ");

class FirstExample { public static void main(string[] args) { System.out.println(" "); { 1 1 {

/* 2010 12 1 */ class FirstExample { public static void main(string[] args) { // System.out.println(" "); 1 /* */ 2 // 1

1 > javac FirstExample.java > java FirstExample 2 Eclipse

Eclipse 1. [ ] [ ] [Java ] 2. [ ] [ ] [ ] 3. [ ] [ ] [Java ]

Compile Error (0) (o) (1) (I) (;) (:) (.) (,)

.java.class FirstExample.java.class FirstExample.class Eclipse workspace

1.Java 2. Java 3.FirstExample.java 4..java.class

2 Java

Ecli System.out.println( class FirstExample { public static void main(string[] args) { System.out.println(" ");

System.out.println( " "Java " ");

1. 2. System.out.println 3. "Java "

int i; // i = 5; // System.out.println(i); //

; 1 int i; 2 double d; 3 boolean boo = false; 4 char c = ' ';

Java

1. double boolean char class Example { public static void main(string args[]) { int i; i = 5; System.out.println(i);

System.out.println(2 + 3);

- *,/ System.out.println(3 + 6 / 3); // 5 System.out.println((3 + 6) /3); // 3

class Example { public static void main(string args[]) { System.out.println(2 + 3);

int i = 10; int j = i * 2; System.out.println(j); // 20 int i = 10; i = i + 3; System.out.println(i); // 13 int i = 10; i += 3; // System.out.println(i); // 13

1. a = a + 5; 2. b = b - 6; 3. c = c * a; 4. d = d / 3; 5. e = e % 2; 6. f = f + 1; 7. g = g - 1;

class CalcExample3 { public static void main(string[] args) { int i; i = 11; i++; i /= 2; System.out.println("i " + i); int j; j = i * i; System.out.println("j " + j);

i = 2 + 3; i = 2 + 3 int i; int j = (i = 2 + 3) * 2; System.out.println(i); // 5 System.out.println(j); // 10

i++; ++i; i 1 j=i++; j=++i; j j = i; i = i + 1; i = i + 1; j = i;

int i = 10; int j = i++; int k = ++i; System.out.println(i); System.out.println(j); System.out.println(k);

double > int

double d = 9.8; int i = d; double d = 9.8; int i = (int)d; (double) (int)

int i = 5; double d = 0.5; System.out.println(i + d); // 5.5 double

int a = 5; int b = 2; double c = a / b; System.out.println(c); // 2.0 5/2 2 d double c = (double)a/(double)b;

7 2 3.5 class Example { public static void main(string[] args) { int a = 7; int b = 2; double d = a / b; System.out.println(d);

String String String s; s = " "; System.out.println(s); + String s1 = " "; String s2 = " String s3 = s1 + s2; System.out.println(s3);

3

if( ) { ; if( ) { ; // true

if(age < 20) { System.out.println("

2 true false

1. a 20 2. a 20 3. a 4. a 5. a 3 6. a 7. a 5 2

if else if( ) { ; else { ; if( ) { // true 1 ; else { // false 2 ;

if else int age; age = 20; if(age < 20) { System.out.println(" "); else { System.out.println("

if else if else int age; age = 20; if(age < 4) { System.out.println(" else if(age < 13) { System.out.println(" else { System.out.println("

if else if( == ) { if( == true) { else { else {

a 3, 5, 8, 9, 10, 15, 20 if(a < 5) { System.out.println("A"); else if(a < 9) { System.out.println("B"); else if(a < 15) { System.out.println("C"); else { System.out.println("D");

if { if 1 { 2 if(age >= 20) System.out.println(" "); if(age >= 20) { System.out.println(" "); { if(age >= 20) System.out.println(" "); System.out.println(" ");

switch break;

switch switch (score) { case 1: System.out.println(" break; case 2: System.out.println(" break; case 3: System.out.println(" "); break; case 4: System.out.println(" "); break; case 5: System.out.println(" "); break; default: System.out.println(" System.out.println("switch "

switch (2) switch (score) { case 1: case 2: System.out.println(" break; case 3: case 4: case 5: System.out.println(" "); break; default: System.out.println("

switch i 1,2,3,4,5 switch(i) { case 1: System.out.println("A"); case 2: break; case 3: System.out.println("B"); case 4: default: System.out.println("C");

3 int c; if(a > b) { c = a; else { c = b; int c = (a > b)? a : b;? 1 : 2 true false 2

3 = > 1000? : ;

c (a) (b) (c) int a = 5; int b = 3; int c = (a > b)? a : b; int a = 5; int b = 3; int c = (a > b * 2)? a + 1 : b - 3; int a = -5; int c = (a > 0)? a : -a;

age 13 age 65 age >= 13 && age < 65 age 13 65 age < 13 age >= 65 age 13 65 20 age >= 13 && age < 65 && age!=20

a + 10 > b * 5 (a + 10) > (b * 5) a > 10 && b < 3 (a > 10) && (b < 3) x && ( y z ) (x && y ) z

if( == &&!= ) {

a,b,c (a) a b b c (b) a b a c (c) a,b,c c (d) c>b>a (e) a c a b (f) a b 2 a b 3

3 for while do while

for for for( ; ; ){ 1. 2. true false for 3. 4. 2.

for for(int i = 0; i < 5; i++) { System.out.println(" ")

for for 1 100 int sum = 0; for(int i = 1; i <= 100; i++) { sum += i; System.out.println(i + " System.out.println(" " + sum );

1. 1 100 2. 1 100 2 3 3. x - 10 10 1 x 2-2x + 1

{ class ForExample2 { public static void main(string[] args) { int sum = 0; for(int i = 1; i <= 100; i++) { sum += i; System.out.println(i + " "); System.out.println(" " + sum );

while while while( ){ 1. true false while 2.1. for

while int i = 0; while(i < 5) { System.out.println(" "); i++; // int i = 5; while(i > 0) { System.out.println(i); i--; //

do while do while do { while( ); 1 1. 2. true 1. false do while for while

do while int i = 0; do { System.out.println(" "); i++; while(i < 5); int i = 5; do { System.out.println(i); i--; while(i > 0);

break; int sum = 0; for(int i = 1; i <= 10; i++) { sum += i; System.out.println(i + " if(sum > 20) { System.out.println(" 20 break; System.out.println(" " + sum );

continue; int sum = 0; for(int i = 1; i <= 10; i++) { if(i % 2 == 0) { continue; sum += i; System.out.println(i + " System.out.println(" " + sum );

for(int a = 1; a <= 3; a++) { System.out.println("a = "+ a); // for(int b = 1; b <= 3; b++) { System.out.println("b = "+ b); // 3 9

1x1=1 2x1=2 3x1=3 4x1=4 5x1=5 6x1=6 7x1=7 8x1=8 9x1=9 1x2=2 2x2=4 3x2=6 4x2=8 5x2=10 6x2=12 7x2=14 8x2=16 9x2=18 1x3=3 2x3=6 3x3=9 4x3=12 5x3=15 6x3=18 7x3=21 8x3=24 9x3=27 1x4=4 2x4=8 3x4=12 4x4=16 5x4=20 6x4=24 7x4=28 8x4=32 9x4=36 1x5=5 2x5=10 3x5=15 4x5=20 5x5=25 6x5=30 7x5=35 8x5=40 9x5=45 1x6=6 2x6=12 3x6=18 4x6=24 5x6=30 6x6=36 7x6=42 8x6=48 9x6=54 1x7=7 2x7=14 3x7=21 4x7=28 5x7=35 6x7=42 7x7=49 8x7=56 9x7=63 1x8=8 2x8=16 3x8=24 4x8=32 5x8=40 6x8=48 7x8=56 8x8=64 9x8=72 1x9=9 2x9=18 3x9=27 4x9=36 5x9=45 6x9=54 7x9=63 8x9=72 9x9=81 class Example { public static void main(string args[]) { for(int i = 1; i <= 9; i++) { for(int j = 1; j <= 9; j++) { System.out.println(); //

1

1. int[] scores; 2. scores = new int[5]; 3. scores[0] = 50; scores[4] = 80; [] 0 ( - 1) 4. System.out.println(scores[2]);

int[] scores; scores = new int[5]; scores[0] = 50; scores[1] = 55; scores[2] = 70; scores[3] = 65; scores[4] = 80; for(int i = 0; i < 5; i++) { System.out.println(scores[i]);

int[] scores = {50, 55, 70, 65, 80; int n = scores.length;

0 1 1 3 2 5 3 6 4 5 5 2 0:* 1:*** 2:***** 3:****** 4:***** 5:** class Example { public static void main(string args[]) { int[] counts = {1, 3, 5, 6, 5, 2;

int[][] scores = new int[3][5]; scores[0][0] = 50; scores[2][3] = 65;

4

class Java class

2 (x=2,y=5) (x= -1,y=3) (0,0) 1 (3,4) 5

2 ( x,y) class Point { int x; Point int y; Point x y int x y 2

class { class {

new Point(); Point p = new Point(); p.x = 10; p.y = 5; Point p = new Point();

Point x y Point p = new Point(); p.x = 10; x

class Point { int x; // x int y; // y Point class PointInstanceExample { public static void main(string[] args) { Point p1 = new Point(); p1.x = 10; p1.y = 5; Point p2 = new Point(); p2.x = 5; p2.y = 2; System.out.println("p1 x " + p1.x); System.out.println("p1 y " + p1.y); System.out.println("p2 x " + p2.x); System.out.println("p2 y " + p2.y);

Java int, double, boolean

Point p = new Point(); p Point

class Dog { String name; class Example { public static void main(string[] args) { Dog dog1 = new Dog(); dog1.name = "Taro"; Dog dog2 = new Dog(); dog2.name = "Pochi"; Dog dog3 = dog2; System.out.println(dog3.name); dog3.name = "Jiro"; System.out.println(dog2.name);

Point p1 = new Point(); Point p2 = new Point(); Point p3 = p2; p1.x = 0; p1.y = 0; p2.x = 5; p2.y = 10;

Point[] points = new Point[5]; points[0] = new Point(); points[1] = new Point(); points[2] = new Point(); points[3] = new Point(); points[4] = new Point();

null Point[] points = new Point[5]; points[0] = new Point(); points[1] = new Point(); points[2] = new Point();

null null Point p; p = null; null Point p = new Point(); if(p == null) { System.out.println("p null"); else { System.out.println("p null

5

Point x,y Point

class { // // void () {

class Point { int x; int y; // void printposition() { System.out.println(" (" + this.x + ", " + this.y + ") "); this Point p = new Point(); p.x = 10; p.y = 5; p.printposition();

void ( ) {

() Point class Point { int x; int y; // x y n void multiply(int n) { this.x *= n; this.y *= n; Point p = new Point(); p.x = 10; p.y = 5; p.multiply(2);

Point class Point { int x; int y; // x y dx dy void add(int dx, int dy) { this.x += dx; this.y += dy; Point p = new Point(); p.x = 10; p.y = 5; p.add(2,3);

( ) { return ;

return 1 Point class Point { Point p = new Point(); int x; p.x = 10; int y; p.y = 5; // x y int getxy() { return this.x*this.y; int xy = p.getxy();

Point class Point { int x; int y; boolean issameposition(point p) { if(this.x == p.x && this.y == p.y) { return true; else { return false; Point p1 = new Point(); p1.x = 10; p1.y = 5; Point p2 = new Point(); p2.x = 10; p2.y = 10; if(p1.issameposition(p2)){ System.out.println(" "); else { System.out.println(" ");

void () { void ( ) { ( ) { return ;

if(this.x == p.x && this.y == p.y) { return true; else { return false; return (this.x == p.x && this.y == p.y); if(p1.issameposition(p2) == true) { if(p1.issameposition(p2)) {

( ) {

Point class Point { int x; int y; Point p = new Point(5, 10); // System.out.println(p.x); Point(int x, int y) { System.out.println(p.y); this.x = x; this.y = y;

class Rectangle { double width; // double height; // 1.Rectangle getarea 2. 3. Rectangle true false

6

2 class Point { int x; int y; void set(int x, int y) { this.x = x; this.y = y; Point p1 = new Point(); p1.set(10, 0); Point p2 = new Point(); p2.set(p1); void set(point p) { this.x = p.x; this.y = p.y;

class Point { int x; int y; Point() { this.x = 0; this.y = 0; Point(Point p) { this.x = p.x; this.y = p.y; Point p1 = new Point(); Point p2 = new Point(10, 20); Point p3 = new Point(p2); Point(int x, int y) { this.x = x; this.y = y;

this this. this. ( ) this( )

this class Point { int x; int y; this.x = x; this.y = y; this void set(int x, int y) { void set(point p) { this.x = p.x; this.y = p.y;

Point counter int class Point { static int counter = 0; int x; int y;

class Point { static int counter = 0; int x; int y;

class Point { static int counter = 0; int x; int y; Point(int x, int y) { this.x = x; this.y = y; Point.counter++; System.out.println( Point.counter); Point p1 = new Point(0, 0); Point p2 = new Point(5, 0); Point p3 = new Point(10, 5); System.out.println( Point.counter);. 1

class Point { this int x; int y; static int counter = 0; Point(int x, int y) { this.x = x; this.y = y; Point.counter++;

. static

class SimpleCalc { // static double gettrianglearea(double base, double height) { return base * height / 2.0; System.out.println(" 10 5 + SimpleCalc.getTriangleArea(10, 5) + " ");

class {

Java [ (1) ] [ [ (1) ] [ (3) ] new [ (3) ] int double [ (5) ] [ (4) ] [ (6) ] [ (6) ] ] (a) (b) (c) (d) (e) (f) (g)null (h) (i)

7

Java A B A B A B B A B A B A

Java Object

extends class A { A class B extends A { B A extends A

Object Object extends Object class A extends Object { A class B extends A {

class Point { int x; int y; void printinfo() { System.out.println(x); System.out.println(y); class ColorPoint extends Point { String color; ColorPoint cp = new ColorPoint(); cp.x = 5; cp.y = 10; cp.color = " ";

class Point { int x; int y; void printinfo() { // class ColorPoint extends Point { String color; void printinfo() { // ColorPoint cp = new ColorPoint(); cp.printinfo();

(1) A B B (2) (3) (4)

super. ( ); class Point { int x; int y; void printinfo() { // class ColorPoint extends Point { String color; void printinfo() { super.printinfo();

super( );

class B extends A { class B extends A { B() { super();

class B extends A { B() { abc(); B(int i) { def(); class B extends A { B() {super();abc(); B(int i) {super(); def();

class X { X() { System.out.println("[X]"); void a() { System.out.println("[x.a]"); void b() { System.out.println("[x.b]"); class Y extends X { Y() { System.out.println("[Y]"); void a() { System.out.println("[y.a]"); X,Y X x = new X(); x.a(); x.b(); Y y = new Y(); y.a(); y.b();

class X { X() { System.out.println("[X()]"); X(int i) { System.out.println("[X(int i)]"); class Y extends X { Y() { System.out.println("[Y()]"); Y(int i) { System.out.println("[Y(int i)]"); class Z extends Y { X,Y Y y0 = new Y(); Y y1 = new Y(10); Z z = new Z();

Point p = new Point(); ColorPoint cp = new ColorPoint(); Point ColorPoint Point cp = new ColorPoint();

class Person { void work() { // " " Person[] persons = new Person[3]; persons[0] = new Person(); class Student extends Person { persons[1] = new Student(); void work() { persons[2] = new Teacher(); // " " class Teacher extends Person { void work() { // " " void maketest() { for(int i = 0; i < 3; i++) { persons[i].work();

// 3 void workthreetimes(person p) { p.work(); p.work(); p.work(); Person new Teacher(), new Student()

A,B,C class A { class B extends A { class C { (1) A a = new A(); (2) A a = new B(); (3) A a = new C(); (4) B b = new A(); (5) B b = new B(); (6) B b = new C();

Person p = new Teacher(); Teacher t = (Teacher)p; t.maketest(); Person p = new Teacher(); ((Teacher)p).makeTest();

private private

private class Car { private int speed; // (Km/h) // speed 1 public void speedup() { if(speed < 80) { speed++; // speed 1 0 public void speeddown() { if(speed > 0) { speed--;

class Example { private int valuea; private int valueb; public int getvaluea() { return valuea; public void setvaluea(int a) { valuea = a; public int getvalueb() { return valueb; public void setvaluea(int b) { valueb = b;

final

public final static double PI = 3.141592653589793; public final static int ADULT_AGE = 20; if(age == 20) { if(age == ADULT_AGE) {

static static int counter = 0; static double getsum(int x, int y) { return x + y; public static void main(string args[]) {

8

abstract abstract class Shape { Shape Shape s = new Shape();

abstract abstract class Shape { abstract void draw();

abstract class Shape { abstract void draw(); class Polyline extends Shape { void draw() { // class Rectangle extends Shape { void draw() { // class Circle extends Shape { void draw() { // Shape[] shapes = new Shape[3]; shapes[0] = new Polyline(); shapes[1] = new Rectangle(); shapes[2] = new Circle(); for(int i = 0; i < 3; i++) { shapes[i].draw();

Java 1

interface { interface HasGetAreaMethod { double getarea(); class implements {

interface HasGetAreaMethod { double getarea(); class Rectangle implements HasGetAreaMethod { double getarea() { return width*height; class Circle implements HasGetAreaMethod { double getarea() { return r*r*3.14; HasGetAreaMethod r = new Rectangle(); HasGetAreaMethod c = new Circle();

interface I { abstract class A { class B extends A { class C implements I { 1. A a = new A(); 2. B b = new B(); 3. C c = new C(); 4. I i = new I(); 5. A b = new B(); 6. B a = new A(); 7. I b = new B(); 8. I c = new C();