downcast and upcast

That is correct. When you do that you are casting it it into an employee object, so that means you cannot access anything manager specific. Downcasting is where you take a base class and then try and turn it into a more specific class. This can be accomplished with using is and an explicit cast … Read more

Why do we assign a parent reference to the child object in Java?

First, a clarification of terminology: we are assigning a Child object to a variable of type Parent. Parent is a reference to an object that happens to be a subtype of Parent, a Child. It is only useful in a more complicated example. Imagine you add getEmployeeDetails to the class Parent: public String getEmployeeDetails() { … Read more

What is the difference between up-casting and down-casting with respect to class variable

Upcasting is casting to a supertype, while downcasting is casting to a subtype. Upcasting is always allowed, but downcasting involves a type check and can throw a ClassCastException. In your case, a cast from a Dog to an Animal is an upcast, because a Dog is-a Animal. In general, you can upcast whenever there is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)