单选题现有两个文件: package X; public class X { public static void doX() {System.out.print ("doX"); } } 和: import x.X; class Find { publiC static void main (String [] args) { X myX=new X(); myX.doX(); X.doX(); x.X.aoX(): x.X myX2=new x.X(); myx2 .doX(); } } 结果为:()A Find类中第4行出现一个错误,编译失败。B Find类第5行出现一个错误,编译失败。C Find类第6行出现一个错误,编译失败。D doX doX doX doX
单选题
现有两个文件: package X; public class X { public static void doX() {System.out.print ("doX"); } } 和: import x.X; class Find { publiC static void main (String [] args) { X myX=new X(); myX.doX(); X.doX(); x.X.aoX(): x.X myX2=new x.X(); myx2 .doX(); } } 结果为:()
A
Find类中第4行出现一个错误,编译失败。
B
Find类第5行出现一个错误,编译失败。
C
Find类第6行出现一个错误,编译失败。
D
doX doX doX doX
参考解析
解析:
暂无解析
相关考题:
下列哪个方法可用于创建一个可运行的类? ( )A.public class X implements Runable {public void run(){...,.,}}B.public class X implements Thread {public void run(){......}}C.public class X implements Thread {public int run(){……}}D.public class X implements Runable {protected void run(){.....}}
在如下源代码文件Test.java中, 哪个是正确的类定义?() A.public class test { public int x = 0; public test(int x) { this.x = x; } }B.public class Test{ public int x=0; public Test(int x) { this.x = x; } }C.public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }D.public class
如下两个源程序文件,分别编译后,运行Example.class文件,运行结果为______。AB.java文件代码如下;package test;public class AB{int a=60;public void show(){System.out.println(”a=”+a);}Example.java文件代码如下:import test.AB;class Example{public static void main(String args[]){AB bj=new AB();obj.show();}}
下列哪个选项的java源文件代码片段是不正确的?A.package testpackage; public class Test{ }B.import java. io. *; package testpaekage; public class Test { }C.import java.io.*; class Person { } public class Test { }D.import java.io.*; import java. awt.*; public class Test{ }
在下列源代码文件Test.java中,正确定义类的代码是( )。A.pblic class test { public int x=0; public test(int x) { this. x=x;} }B.public class Test { public int x=0; public Test(int x) { this. x=x;} }C.public class Test extends T1,T2{ public int x = 0; public Test(int x){ this. x = x; } }D.protected class Test extends T2{ public int x = 0; public Test(int x) { this. x = x; } }
有如下程序: include class x { protected: int a; public:x(){ a=1;} }; class x 有如下程序: #include <iostream.h> class x { protected: int a; public: x() { a=1; } }; class x1 : virtual public x { public: x1() { a+=1; cout<<a; } }; class x2 : virtual public x { public: x2() { a+=2; cout<<a; } }; class y : public xl,public x2 { public: y() { cout<<a<<end1; } }; int main() { y obj; return O; } 该程序运行后的输出结果是( )。A.1B.123C.242D.244
下列哪个选项的java源文件程序段是不正确的? ( )A.package testpackage; public class Test{ }B.import java.io.*; package testpackage; public class Test{ }C.import java.i.*; class Person{} public class Test{ }D.import java.io.*; import java.awt.*; public class Test { }
下面程序段的输出结果为 package test; public class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println(”x=”+b.x); } } class Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }A.x=10B.x=20C.x=6D.编译不通过
在下列源代码文件Test.java中, ( )是正确的类定义。A.public class test{B.public class Test{ public int x=0;public int x=0; public test (intx) public Test (int x){ {this.x=x; this.x=x;} }} }C.public class Test extends T1,T2{D.protected class Test extends T2{ public int=0;public int x=0; public Test(int x){Public Test (int x){ this.x=x;this.x=x: }} }}
在下列源代码文件Test.java中,哪个选项是正确的类定义? ( )A.public class test { public int x=0; public test(int x) { this.x=x; } }B.public class Test { public int x=0; public Test(int x) { this.x=x; } }C.public class Test extends Ti,T2 { public int x=0; public Test(int x) { this.x=x; } }D.protected class Test extends T2 { public int x=0; public Test(int x) { this.x=x; } }
package test1; public class Test1 { static int x = 42; } package test2; public class Test2 extends test1.Test1 { public static void main(String[] args) { System.out.println(“x = “ + x); } } What is the result?() A、 x = 0B、 x = 42C、 Compilation fails because of an error in line 2 of class Test2.D、 Compilation fails because of an error in line 3 of class Test1.E、 Compilation fails because of an error in line 4 of class Test2.
Which three demonstrate an “is a” relationship?() A、 public class X { } public class Y extends X { }B、 public interface Shape { } public interface Rectangle extends Shape{ }C、 public interface Color { } public class Shape { private Color color; }D、 public interface Species { } public class Animal { private Species species; }E、 public class Person { } public class Employee { public Employee(Person person) { }F、 interface Component { } class Container implements Component { private Component[] children; }
现有两个文件:A package x; public class X{ public static void doX(), System.out.print(“doX”); } 和: Import x,X; class Find{ public static void main(String[] args){ X myX =new X(); myX.doX(); X.doX(); x.X. doX(); x.X myX2=new x.x(); myX2.doX(); } } 结果为:() A、 doX doX doX doXB、 Find类中出现多个错误,编译失败。C、 Find类中第4行出现一个错误,编译失败。D、 Find类中第5行出现一个错误,编译失败。E、 Find类中第6行出现一个错误,编译失败。F、 Find类中第7行出现一个错误,编译失败。
现有2 个文件: 1. package x; 2. public class X { 3. public static void doX() { System.out.print("doX "); } 4. } 和: 1. class Find { 2. public static void main(String [] args) { 3. //insert code here 4. } 5. } 哪两行分别插入到类Find 的第3 行将编译并产生输出“doX”? ()A、doX();B、X.doX();C、x.X.doX();D、x.X myX = new x.X(); myX.doX();
现有两个源文件: package com.sun; public class PkgAccess { public static int tiger = 1414; } 和 import com.sun.PkgAccess; public class PkgAccess2 { int x1 = PkgAccess.tiger; int x2 = tiger; int x3 = com.sun.PkgAccess.tiger; int x4 = sun.PkgAccess.tiger; } 下面哪两项是正确的?()A、PkgAccess2 类可编译。B、由于第5 行发生错误编译失败。C、由于第6 行发生错误编译失败。D、由于第8 行发生错误编译失败。
public class X { public X aMethod() { return this;} } public class Y extends X { } Which two methods can be added to the definition of class Y?()A、 public void aMethod() {}B、 private void aMethod() {}C、 public void aMethod(String s) {}D、 private Y aMethod() { return null; }E、 public X aMethod() { return new Y(); }
package geometry; public class Hypotenuse { public InnerTriangle it = new InnerTriangle(); class InnerTriangle { public int base; public int height; } } Which is true about the class of an object that can reference the variable base? ()A、 It can be any class.B、 No class has access to base.C、 The class must belong to the geometry package.D、 The class must be a subclass of the class Hypotenuse.
现有2个文件: package x; public class X{ public static void doX() {System.out.print("doX");} } 和: class Find{ public static void main(String [] args) { //insert code here } } 哪两行分别插入到类Find的第3行将编译并产生输出“doX”?()A、doX();B、X.doX();C、x.X.doX();D、x.X myX=new x.X();myX.doX();
现有: class Top { static int x=l; public Top (inty) { x*=3; } } class Middle extends Top { public Middle() {x+=1; ) public static void main (String [] args) { Middle m = new Middle(); System. out .println (x); } } 结果为:() A、1B、2C、3D、编译失败
现有 public class Parentt public void change (int x){) ) public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?() A、 protected void change (int x){}B、 public void change(int x, int y){}C、 public void change (int x){}D、 public void change (String s){}
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()A、 public class Circle implements Shape { private int radius; }B、 public abstract class Circle extends Shape { private int radius; }C、 public class Circle extends Shape { private int radius; public void draw(); }D、 public abstract class Circle implements Shape { private int radius; public void draw(); }E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
多选题现有2 个文件: 1. package x; 2. public class X { 3. public static void doX() { System.out.print("doX "); } 4. } 和: 1. class Find { 2. public static void main(String [] args) { 3. //insert code here 4. } 5. } 哪两行分别插入到类Find 的第3 行将编译并产生输出“doX”? ()AdoX();BX.doX();Cx.X.doX();Dx.X myX = new x.X(); myX.doX();
单选题package geometry; public class Hypotenuse { public InnerTriangle it = new InnerTriangle(); class InnerTriangle { public int base; public int height; } } Which is true about the class of an object that can reference the variable base? ()A It can be any class.B No class has access to base.C The class must belong to the geometry package.D The class must be a subclass of the class Hypotenuse.
多选题现有2个文件: package x; public class X{ public static void doX() {System.out.print("doX");} } 和: class Find{ public static void main(String [] args) { //insert code here } } 哪两行分别插入到类Find的第3行将编译并产生输出“doX”?()AdoX();BX.doX();Cx.X.doX();Dx.X myX=new x.X();myX.doX();
单选题package test1; public class Test1 { static int x = 42; } package test2; public class Test2 extends test1.Test1 { public static void main(String[] args) { System.out.println(“x = “ + x); } } What is the result?()A x = 0B x = 42C Compilation fails because of an error in line 2 of class Test2.D Compilation fails because of an error in line 3 of class Test1.E Compilation fails because of an error in line 4 of class Test2.
单选题现有 public class Parentt public void change (int x){) ) public class Child extends Parent{ //覆盖父类change方法 } 下列哪个声明是正确的覆盖了父类的change方法?()A protected void change (int x){}B public void change(int x, int y){}C public void change (int x){}D public void change (String s){}
单选题现有: class Top { static int x=l; public Top (inty) { x*=3; } } class Middle extends Top { public Middle() {x+=1; ) public static void main (String [] args) { Middle m = new Middle(); System. out .println (x); } } 结果为:()A1B2C3D编译失败