HR자바 Java Method Overriding 2 (Super Keyword)

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:51 판 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

개요[ | ]

HR자바 Java Method Overriding 2 (Super Keyword)
해커랭크 Java
# 문제 비고
HR자바 Object Oriented Programming e
43 HR자바 Java Inheritance I
44 HR자바 Java Inheritance II
45 HR자바 Java Abstract Class
46 HR자바 Java Interface
47 HR자바 Java Method Overriding
48 HR자바 Java Method Overriding 2 (Super Keyword)
49 HR자바 Java Instanceof keyword
50 HR자바 Java Iterator

import java.util.*;
import java.io.*;

class BiCycle{
	String define_me(){
		return "a vehicle with pedals.";
	}
}

class MotorCycle extends BiCycle{
	String define_me(){
		return "a cycle with an engine.";
	}
	
	MotorCycle(){
		System.out.println("Hello I am a motorcycle, I am "+ define_me());
		String temp=super.define_me(); //Fix this line
		System.out.println("My ancestor is a cycle who is "+ temp );
	}
}

class Solution{
	public static void main(String []args){
		MotorCycle M=new MotorCycle();
	}
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}