/*
class Pen{
private int amount;
public int getAmount() {return amount;}
public void setAmount(int amount) {this.amount=amount;}
}
class Sharp extends Pen{
private int width;
}
class Ball extends Pen{
private String color;
public String getColor() {return color;}
public void setColor(String color) {this.color=color;}
}
class Fountain extends Ball{
public void refill(int n) {setAmount(n);}
}
*/
/*
class Person{
private int age, money;
String name;
public Person() {
System.out.println("Person 기본 생성자 실행됨");
}
public Person(int money) {
this.money = money;
}
}
class Student extends Person{
String school, grade;
public Student () {
super(0);
System.out.println("student 기본 생성자 실행됨");
}
public Student(String school) {
super(0);
this.school = school;
}
}
class Main{
public static void main(String[] args) {
Student s = new Student("특목코");
}
}*/
/*class Point{
private int x,y;
public Point() {
this.x=this.y=0;
}
public Point(int x,int y) {
this.x=x;this.y=y;
}
public void showPoint(){
System.out.println("("+x+","+y+")");
}
}
class ColorPoint extends Point{
private String color;
public ColorPoint(int x,int y,String color) {
super(x,y);
this.color=color;
}
public void showColorPoint() {
System.out.print(color);
showPoint();
}
}
public class Main{
public static void main(String[] args) {
ColorPoint cp= new ColorPoint(5,6,"blue");
cp.showColorPoint();
}
}
강제형변환 캐스팅 casting
*/
/*
class Person{
private int age, money;
String name;
public Person() {
System.out.println("Person 기본 생성자 실행됨");
}
public Person(int money) {
this.money = money;
}
}
class Student extends Person{
String school, grade;
public Student () {
System.out.println("student 기본 생성자 실행됨");
}
public Student(String school) {
this.school = school;
}
}
class Teacher extends Person{
String school;
public Teacher () {
System.out.println("teacher 기본 생성자 실행됨");
}
public Teacher(String school) {
this.school = school;
}
}
class Main{
public static void main(String[] args) {
Person p = new Teacher(); // 업캐스팅
//p.school = "특목코"; //컴파일 오류
//다운캐스팅
// Person p = new Person();
// Student s = (Student)p;
//instanceof 로 p레퍼런스변수가 가리키는 곳에 실제로 어떤 객체가 들어있는지 판별 가능하다!!
if(p instanceof Student) {
System.out.println("p에는 실제로 Student 객체가 들어있어요!");
}
if( p instanceof Teacher) {
System.out.println("p에는 실제로 Teacher 객체가 들어있어요!");
}
}
}
*/
class TV {
private int size;
public TV(int size) {
this.size = size;
}
protected int getsize() {
return size;
}
}
class ColorTV extends TV {
int nbc;
public ColorTV(int a, int b) {
super(a);
nbc = b;
}
public void print() {
System.out.println(this.getsize() + "인치" + nbc + "컬러");
}
}
public class Main {
public static void main(String[] args) {
ColorTV myTV = new ColorTV(32, 1024);
myTV.print();
}
}



