Các câu hỏi phỏng vấn và câu trả lời về phần "Core Java - OOPs concepts: Initial OOPs" - Phần 3: Thừa kế (inheritance)
1) What is this in java?
It is a keyword that that refers to the current object.
2) What is Inheritance?
Inheritance is a mechanism in which one object acquires all the properties and behaviour of another object of another class. It represents IS-A relationship. It is used for Code Resusability and Method Overriding.
3) Which class is the superclass for every class.
Object class.
To reduce the complexity and simplify the language, multiple inheritance is not supported in java in case of class
Holding the reference of the other class within some other class is known as composition.
Aggregation represents weak relationship whereas composition represents strong relationship. For example: bike has an indicator (aggregation) but bike has an engine (compostion).
Pointer is a variable that refers to the memory address. They are not used in java because they are unsafe(unsecured) and complex to understand.
It is a keyword that refers to the immediate parent class object
No. Because super() or this() must be the first statement.
The object cloning is used to create the exact copy of an object.
Nguyễn Thị Bảo Trang
» Tin mới nhất:
» Các tin khác: