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 1: Hàm tạo (constructor)
Có hơn 50 câu hỏi phỏng vấn về OOPs (Lập trình hướng đối tượng và hệ thống). Để dễ hiểu và hệ thống giữa các kiến thức trong phần này,các câu hỏi được phân loại thành nhiều phần như: Hàm tạo (constructor), thuộc tính và phương thức tĩnh (static), tính thừa kế (inheritance), tính trừu tượng (abstraction), tính đa hình (polymorphism)
1) What is difference between object oriented programming language and object based programming language?
Object based programming languages follow all the features of OOPs except Inheritance. Examples of object based programming languages are JavaScript, VBScript etc.
2) What will be the initial value of an object reference which is defined as an instance variable?
The object references are all initialized to null in Java.
CONSTRUCTOR INTERVIEW QUESTIONS
3) What is constructor?
Constructor is just like a method that is used to initialize the state of an object. It is invoked at the time of object creation
4) What is the purpose of default constructor?
The default constructor provides the default values to the objects. The java compiler creates a default constructor only if there is no constructor in the class
5) Does constructor return any value?
yes, that is current instance (You cannot use return type yet it returns a value)
6)Is constructor inherited?
No, constructor is not inherited
7) Can you make a constructor final?
No, constructor can't be final.
» Tin mới nhất:
» Các tin khác: