Sort by

recency

|

138 Discussions

|

  • + 0 comments

    Java Logic

    String temp=super.define_me();

  • + 0 comments

    In Java, method overriding allows a subclass to provide its own implementation of a method that is already defined in its parent class. When overriding, the method in the subclass must have the same name, return type, and parameters as the parent’s method. Winbuzz Login

  • + 0 comments

    Why am I only seeing the Solution class? I do not see any other class nor interface in this activity.

  • + 0 comments
    import java.io.*;
    import java.util.*;
    
    class Cycle{
        private String technology = "pedals";
        void myFunc(){
            System.out.println("My ancestor is a cycle who is a vehicle with " + technology +  ".");
        }
    }
    
    class Motorcycle extends Cycle{
        private String technology = "engine";
        void myFunc(){
            System.out.println("Hello I am a motorcycle, I am a cycle with an " + technology +  ".");
        }
        void displayInfo(){
            myFunc();
            super.myFunc();
        }
    }
    
    public class Solution {
    
        public static void main(String[] args) {
            Motorcycle honda = new Motorcycle();
            honda.displayInfo();
        }
    }
    
  • + 0 comments

    This is especially useful when the child class wants to enhance or customize behavior without losing the parent’s implementation. It demonstrates key principles of inheritance, polymorphism, and code reuse, which are fundamental to object-oriented programming in Java. Gold365 Login ID and Password