Question
Examine the following Java-like code:   ```java   class Parent {     String name = "Parent";     public void display() {       System.out.println(name);     }   }   class Child extends Parent {     String name = "Child";     // No display method override   }   public class Main {     public static void main(String[] args) {       Parent p = new Child();       p.display();     }   }   ```   What will be the output?
Solution
This demonstrates variable hiding (not overriding) and method overriding. Â Â Â Â Â Â `Parent p = new Child();` creates a `Child` object but the reference `p` is of type `Parent`. Â Â Â Â Â Â When `p.display()` is called, Java uses dynamic method dispatch (polymorphism) to call the `display()` method of the actual object type, which is `Child`. Â Â Â Â Â Â However, `Child` does not override the `display()` method. Therefore, the `display()` method from the `Parent` class is executed. Â Â Â Â Â Â Inside `Parent.display()`, `name` refers to `Parent.name`, which is "Parent". The `Child`'s `name` variable is a separate, hidden variable.
- Which SQL command is used to add new rows of data into a table?
- What is a table joined with itself called?
- Which of the following is true about the primary key in a relational database?
- Which of the following schedules is serializable?
- What is the purpose of 'indexing' in a database?
- Which type of join returns only matching records from both tables?
- A system is in a safe state when:
- Which of the following is a transaction property ensuring all steps are completed or none?
- Which of the following SQL queries would return the total number of employees in each department, but only for departments with more than 10 employees?
- Consider the following Java code snippet public class Car {   private String model;   private int year;   public Car(String model, int year) {...