题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-01-30 20:13:33

[单选题] 在同一目录编译和运行以下两文件结果如何 ?
// 文件 P1.java
Package MyPackage;
Class P1{
Void afancymethod(){
System.out.println("What a fancy method");
}
}
// 文件 P2.java
Public class P2 extends P1{
Public static void main(String argv[]){
P2 p2 = new P2();
P2.afancymethod();
}
}
A.两个均通过编译, P2 运行时输出 What a fancy method
B.没一个通过编译
C.两个均通过编译,但 P2 运行时出错
D. P1 通过编译,但 P2 出现编译错误

更多"[单选题] 在同一目录编译和运行以下两文件结果如何 ?// 文件 "的相关试题:

[单选题] 给定如下一个Java源文件Child.java,编译并运行Child.java,以下结果正确的是()。
Class Parent1 {
Parent1(String s){
System.out.println(s);
}
}
Class Parent2 extends Parent1{
Parent2(){
System.out.println("parent2");
}
}
Public class Child extends Parent2 {
Public static void main(String[] args) {
Child child = new Child();
}
}
A. 编译错误:没有找到构造器Child() {}
B. 编译错误:没有找到构造器Parent1(){}
C. 正确运行,没有输出值
D. 正确运行,输出结果为:parent2
[单选题]以下程序的编译和运行结果为?
Abstract class Base{
Abstract public void myfunc();
Public void another(){
System.out.println("Another method");
}
}
public class Abs extends Base{
public static void main(String argv[]){
Abs a = new Abs();
a .amethod();
}
public void myfunc(){
System.out.println("My Func");
}
public void amethod(){
myfunc();
}
}
A.输出结果为 My Func
B.编译指示 Base 类中无抽象方法
C.编译通过,但运行时指示 Base 类中无抽象方法
D.编译指示 Base 类中的 myfunc 方法无方法体,没谁会喜欢该方法。
[单选题]在JavaEE中,给定某Servlet的代码如下,编译运行该文件,以下陈述正确的是( )。 public class Servlet1 extends HttpServlet{   public void init() throws ServletException{ }   public void service (HttpServletRequest request,HttpServletResponse response)Throws ServletException,IOException{     PrintWriter out = response.getWriter();     out.println(“Hello World JSP!”);   } }
A.编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过
B.编译后,把Servlet1.class放在正确位置,运行该Servlet,在浏览器中会看到输出文字:Hello World JSP!
C.编译后,把Servlet1.class放在正确位置,运行该Servlet,在浏览器中看不到任何输出的文字
D.编译后,把Servlet1.class放在正确位置,运行该Servlet,在浏览器中会看到运行错误信息
[单选题] 在Java中,以下程序编译运行后的输出结果为( )。
Public class Test {
Int x, y;
Test(int x, int y) {
This.x = x;
This.y = y;
}
Public static void main(String[] args) {
Test pt1, pt2;
Pt1 = new Test(3, 3);
Pt2 = new Test(4, 4);
System.out.print(pt1.x + pt2.x);
}
}
A. 6
B. 3 4
C. 8
D. 7
[单选题]下列代码编译和运行的结果是:()
Public static void main(String[] args) {
String[] names = { "Oscar", "Edgar", "Frank", "Laurent","Hugo","Jacob", "Aaron", "Gino", "Angus", "Ken" };
System.out.println(names[10]);
}
A.编译错误
B.运行时抛出异常
C.输出:ken
D.输出:Angus
[单选题]下列程序编译或运行的结果是:()
Public static void main(String[] args) {
Int num = 100;
For(int i=0;i<=100;i++) {
Int num = 10;
}
System.out.println(num);
}
A. 10
B. 100
C. 201
D.编译不通过
[单选题] 下列代码段编译和运行的结果是:()
Public static void main(String[] args) {
For (int i = 0; i <= 10; i++) {
If (i > 6){
Break;
}
}
System.out.println(i);
}
A.输出 6
B.输出 7
C.输出 10
D.编译错误
[单选题]编译并运行以下程序段的结果是:( )
Public class MyClass{
Final static int i;
MyClass(){i =0;}
Public static void main(String args[]){
System.out.println(i);
}
}
A.编译出错
B.null
C.1
D.0
[填空题]二级目录结构是将文件目录分成( )_文件目录和用户文件目录两级。
[填空题]二级目录结构是将文件目录分成主文件目录和( )_文件目录两级。
[单选题]Java 编译输出文件的后缀是:
A..exe
B..java
C..class
D..obj
[单选题]下列代码的编译或执行结果是: public class MyVal { public static void main(String[] args) { MyVal m = new MyVal(); m.aMethod(); } public void aMethod(){ boolean [] b = new Boolean [5]; System.out.println(b[0]); } }
A.1
B.null
C.0
D.编译错误
[单选题]3号线FAS系统网关进入文件目录后如何进入编辑状态()?
A.按"I"键
B.按"E"键
C.按"D"键
D.按"A"键
[单选题]下列代码编译或执行结果的描述中,正确的是: class Test{ public static void main(String args[]){ TestThread pm1 = new TestThread("One"); pm1.start(); TestThread pm2 = new TestThread("Two"); pm2.start(); } } class TestThread extends Thread{ private String sTname=""; TestThread(String s){ sTname = s; } public void run(){ for(int i=0;i<2;i++){ try { sleep(1000); } catch (InterruptedException e) {} System.out.println(sTname+" "); } } }
A.不能通过编译,TestThread 类中不能定义变量和构造方法
B.输出One One Two Two
C.输出Two One One Two
D.选项B 或C 都有可能出现
[判断题]主机用户在目录一级所拥有的权限仅对该目录下所有文件有效,该目录下的子目录权限需另行授权。
A.正确
B.错误
[单选题]HTML文件必须由特定的程序进行编译和执 行才能显示,这种编译器就是().
A.A:文本编辑器
B.B:解释程序
C.C:编译程序
D.D:Web浏览器
[单选题]在Windows环境下,由C++源程序文件编译而成的目标文件的扩展名是( )。
A. cpp
B. exe
C. o 或 obj
D. lik

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码