首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序打包到example包,main方法调用线程类输出0~9这10个数,请填写横线处的内容。 注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。 ______ interface MyInterface
下列程序打包到example包,main方法调用线程类输出0~9这10个数,请填写横线处的内容。 注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。 ______ interface MyInterface
admin
2009-01-15
31
问题
下列程序打包到example包,main方法调用线程类输出0~9这10个数,请填写横线处的内容。
注意:请勿改动main()主方法和其他已有语句内容,仅在横线处填入适当语句。
______
interface MyInterface
{
public abstract void print(int n);
}
class Mythread extends Thread ______ MyInterface
{
public void run()
{
for(int i = 0; i < 10; i++)
this.print(i);
}
public void print(int n)
{
System.out.print(n +" ");
}
}
public class Example1_6
{
public static void main(String argv[])
{
Mythread th = new Mythread();
______
}
}
选项
答案
①package example; ②implements ③th.start();
解析
MyInterface是自定义的一个接口,Mythread继承于Thread类同时实现了 MyInterface。主方法先根据Mythread生成一个线程,然后将其启动。
第1个空,题目中已经说明要将本程序打包到 example包,则说明要使用关键字“package”。
第2个空,接口是抽象方法和常量的结合,是一种特殊的抽象类,接口必须通过“implements”实现以后才能被使用。所有线程都通过start()启动,进入线程调度队列。然后,系统会根据一定的算法对线程的运行进行调度,run()方法是线程的线程体。故第3空应该填“th.start()”。
转载请注明原文地址:https://kaotiyun.com/show/Ymnp777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
根据“歌手”表建立视图myview,视图中含有“歌手号”左边第一位是“1”,的所有记录,正确的SQL语句是
在下列模式中,能够给出数据库物理存储结构与物理存取方法的是
在软件开发中,需求分析阶段产生的主要文档是
对下列二叉树进行前序遍历的结果是
表单文件的扩展名是
在VisualFoxPro中,下面关于属性、方法和事件的叙述错误的是
下列关于类、对象、属性和方法的描述中错误的是()。
如果在命令窗口执行命令:LIST名称,主窗口中显示:记录行名称1电视机2计算机3电扇线4电脑连线5电话线假定名称字段为字符型,宽度为8,那么下面程序段的输出结果是()。GO2SCAN
项目管理器的“文档”选项卡用于显示和管理
每个applet必须定义为______的子类。
随机试题
A.生之本B.气海C.水谷之海D.仓廪之本胃为
叙述节流装置的测量原理,并写出质量流量基本计算公式。
价值原则
脑出血患者急性期一般采取何种卧位
血型不合输血后,患者出现严重溶血反应,实验室检查的重要依据是
会计职业道德中的“提高技能”,其主要内容包括()。
孔子的许多教诲,说来都挺好听,诸如“刚、毅、木、讷”,“温、行、忠、信”以及“温、良、恭、俭、让”等等,都不失为“为人之道”。然而,这些“优良品质”历来都是统治者、强者以及教育者用来_________被统治者、弱者和受教育者的,他们自己一个个却未必____
吕骥撰写的_________是中国近代最早论述民间音乐的分类及研究方法的文章。
【反击右倾翻案风】
设窗体上有一个列表框控件List1,含有若干列表项。以下能表示当前被选中的列表项内容的是
最新回复
(
0
)