1.) public class Building {//whatever} public class House extends Building {//whatever} is this legal? Building b = new House(); is this legal? House h = new Building(); 2.) unary operation is automatically converted to "int" except += or -- so is this legal? char c = 'a'; c++; //byte or int? or this? byte b = 1; b++; //returns byte or int? so what's an example of another unary operator that automatically casts char, byte and short to int? Thanks guys, i know my question is awkwardly stated. I'm just in a rush before I forget.
(I) is this legal? Building b = new House(); yes it is legal both during compile time and run time (II) is this legal? House h = new Building(); this is not legal during compile time as the Building instance needs to be explicitly casted to a House instance. (III) so is this legal? char c = 'a'; c++; //byte or int? this is legal and will return a char. Th unary operators of ++ and -- implicitly cast the primitive varibale to the varibale type (IV) byte b = 1; b++; The same reasoning of (III) holds.. Hope this helps Anand