본문 바로가기 메뉴 바로가기

Studying programming

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Studying programming

검색하기 폼
  • Jimin's Programming (194)
    • Algorithms (54)
    • JavaScript (16)
    • Vue.js (3)
    • Node.js (3)
    • React.js (7)
    • React Native (0)
    • Spring Boot (13)
    • JAVA (58)
    • C++ (17)
    • Programming (19)
    • Computer basics (4)
  • 방명록

Object type casting (2)
Object type casting(upcasting,downcasting) example in Java

Upcasting을 이용하면 부모객체로 부터 상속받은 메서드를 사용할 수 있게된다. 즉, 단 하나의 부모클래스의 객체(PhoneInfo)로 여러가지 자식 메서드(univPhoneInfo, companyPhoneInfo, friendPhoneInfo)를 검색할 수 있는 장점이 있다. Example I public class PhoneInfo { String name; String phoneNum; public PhoneInfo(String name, String num){ this.name = name; phoneNum = num; } public void showInfo(){ System.out.println("name: " + name); System.out.println("phone: " + phon..

JAVA 2019. 6. 17. 08:06
Upcasting (Object type casting) in java

Upcasting Upcasting is casting from a subclass to superclass. When a superclass variable contains a reference to a subclass object, and that reference is used to call a method, the subclass version of the method is called. Student s = new Student (); Person p = (person)s; ↓ Person p = new Student();Reference variable object Upcasting happens if you want to reuse your code that knows about the su..

JAVA 2019. 1. 30. 10:02
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • Object type casting
  • 프로그래머스 알고리즘
  • rest parameter
  • math.abs
  • java
  • HashMap
  • hackerrank solution
  • hackerrank
  • 프로그래머스
  • substring()
  • ... in Javascript
  • compareTo()
  • hackerrank javascript
  • math.max
  • 프로그래머스 알고리즘문제
  • HackerRank Algorithm
  • Collection Framework
  • spring boot application
  • easy javascript algorithm
  • Javascript Algorithm
  • javascript
  • repeat()
  • code refactoring
  • C++
  • hackerrank javascript solution
  • 알고리즘
  • equals()
  • string class in java
  • algorithm
  • easy algorithm
more
«   2025/06   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바