Java 4일차 Abstract 활용 테스트(+final)

final class FinalClass
{
final int i = -999999;
}

abstract class AbstractClass
{
abstract String abstractMethod(int i, String s);
int finalMethod(int i, int j)
{
return i+j;
}
}

class Sample01 extends AbstractClass
{
String abstractMethod(int i, String s)
{
System.out.println("return "+s+i);
return s+i;
}

int finalMethod(int i, int j)
{
return i*j;
}
}

class Sample03 extends AbstractClass
{
String abstractMethod(int i, String s)
{
System.out.println("return "+s+", "+i);
return s+", "+i;
}

void sampleMethod03()
{
System.out.println("void sampleMethod03() 호출 됨");
}
}

public class AbstractTest
{
public static void main(String args[])
{
// AbstractClass ac = new AbstractClass();
FinalClass fc = new FinalClass();
// fc.i = 100000;
Sample01 s01 = new Sample01();
AbstractClass acS01 = new Sample01();
AbstractClass acS03 = new Sample03();

System.out.println(s01.finalMethod(50, 100));

acS01.abstractMethod(700, "999");
acS03.abstractMethod(700, "999");
}
}

댓글 없음: