php 面向对象 试题,PHP面向对象-测试题(6~10) | 学步园

这篇博客探讨了PHP4与PHP5之间的对象导向编程(OOP)差异,包括抽象方法、接口、私有方法等概念。通过示例代码展示了如何在PHP中模拟未在PHP4中支持的OOP构造,如接口实现和抽象方法。同时,讨论了类的构造函数、对象序列化自定义以及在类内部调用方法的方式。
摘要由CSDN通过智能技术生成

6. What OOP construct unavailable in PHP 4 does the following script approximate?

class my_class

{

function my_funct ($my_param)

{

user_error ("Please define me", E_ERROR);

}

function b()

{

return 10;

}

}

A. Multiple inheritance

B. Interfaces

C. Abstract methods

D. Private methods

E. Function overloading

7. Assume that a class called testclass is defined. What must the name of its constructor method be?

A. __construct

B. initialize

C. testclass

D. __testclass

E. Only PHP 5 supports constructors

8. How can a class override the default serialization mechanism for its objects?

A. By implementing the __shutdown and __startup methods

B. By calling register_shutdown_function()

C. By implementing __sleep() and __wakeup()

D. The default serialization mechanism cannot be overridden

E. By adding the class to the output buffering mechanism using ob_start()

9. In PHP 4, which object-oriented constructs from the following list are not available?

- Abstract classes

- Final classes

- Public, private, protected (PPP) methods

- Interfaces

A. Abstract classes

B. PPP methods

C. Neither PPP methods nor interfaces

D. None of the above are available

E. All of the above are available

10. How would you call the mymethod method of a class within the class itself?

A. $self=>mymethod();

B. $this->mymethod();

C. $current->mymethod();

D. $this::mymethod();

E. None of the above are correct

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值