下列程序中注释的哪个代码(1、2、3、4)是错误的(无法通过编译)?
abstract class A {
abstract float getFloat (); //1
void f() //2
{ }
}
public class B extends A {
private float m = 1.0f; //3
private float getFloat () //4
{ return m;
}
}
选项:
A:
1
B:
2
C:
3
D:
4
abstract class A {
abstract float getFloat (); //1
void f() //2
{ }
}
public class B extends A {
private float m = 1.0f; //3
private float getFloat () //4
{ return m;
}
}
1
2
3
4
以下文字与答案无关
提示:有些试题内容 显示不完整,文字错误 或者 答案显示错误等问题,这是由于我们在扫描录入过程中 机器识别错误导致,人工逐条矫正总有遗漏,所以恳请 广大网友理解。
byte ] a="abcd".getBytes();
try{ FileOutputStream out=new FileOutputStream(f);
out.write(a);
out.close();
FileInputStream in=new FileInputStream(f);
byte ] tom= new byte3];
int m = in.read(tom,0,3);
System.out.println(m); //【代码1】
String s=new String(tom,0,3);
System.out.println(s); //【代码2】
m = in.read(tom,0,3);
System.out.println(m); //【代码3】
s=new String(tom,0,3);
System.out.println(s); //【代码4】
}
catch(IOException e) {}
}
}
">5.上机调试题:请说出E类中标注的【代码1】~【代码4】的输出结果。
import java.io.*;
public class E {
public static void main(String args]) {
int n=-1;
File f =new File("hello.txt");
byte ] a="abcd".getBytes();
try{ FileOutputStream out=new FileOutputStream(f);
out.write(a);
out.close();
FileInputStream in=new FileInputStream(f);
byte ] tom= new byte3];
int m = in.read(tom,0,3);
System.out.println(m); //【代码1】
String s=new String(tom,0,3);
System.out.println(s); //【代码2】
m = in.read(tom,0,3);
System.out.println(m); //【代码3】
s=new String(tom,0,3);
System.out.println(s); //【代码4】
}
catch(IOException e) {}
}
}
Byte]a= "abcd" . getBytes();
Try{ FileOutputStream out = new FileOutputStream(f);
Out.write(a);
Out.close();
FileInputStream in = new FileInputStream(f);
Byte] tom= new byte 3];
Int m= in. read(tom, 0,3);
System. out. println(m);//【代码1】
String s = new String(tom, 0, 3);
System. out. println(s); //代码2】
M= in.read(tom, 0, 3);
System. out. println(m);//代码3】
S = new String( tom, 0,3);
System. out. println(s);//【代码4】
Catch( IOException e){}
}
}
">6.请说出E类中标注的【代码1】~【代码4】的输出结果。Import java.io. *;
Public class E{
Public static void main(String args ]){
Int n= - 1;
File f = new File( " hello.txt");
Byte]a= "abcd" . getBytes();
Try{ FileOutputStream out = new FileOutputStream(f);
Out.write(a);
Out.close();
FileInputStream in = new FileInputStream(f);
Byte] tom= new byte 3];
Int m= in. read(tom, 0,3);
System. out. println(m);//【代码1】
String s = new String(tom, 0, 3);
System. out. println(s); //代码2】
M= in.read(tom, 0, 3);
System. out. println(m);//代码3】
S = new String( tom, 0,3);
System. out. println(s);//【代码4】
Catch( IOException e){}
}
}
1, 2, 3, 4, 5]
1, 2, 3], 4, 5]]
C:
1, 2, 3], 4, 5]
1, 2, 3, 4, 5]]
1:1
B:2:1
C:3:1
D:4:1
out.write(a);
out.close();
FileInputStream in = new FileInputStream(f);
byte ] tom = new byte3];
int m = in.read(tom,0,3);
System.out.println(m); //代码1] (3)
String s = new String(tom,0,3);
System.out,println(s): //代码2](abc)
m= in.read(tom,0,3);
System.out.println(m) //代码3] (1)
s =new String(tom,0,3)
System.out.println(s): //代码4] (abc)
catch(IOException e)(]
">12.请说出 E类中标注的代码 1]一代码4]的输出结果import java.io.;public class E(public static void main(String args ]) (intn=-1;File f = new File("hello.txt");byte] a= "abcd".getBytes();try| FileOutputStream out = new FileOutputStream(f);
out.write(a);
out.close();
FileInputStream in = new FileInputStream(f);
byte ] tom = new byte3];
int m = in.read(tom,0,3);
System.out.println(m); //代码1] (3)
String s = new String(tom,0,3);
System.out,println(s): //代码2](abc)
m= in.read(tom,0,3);
System.out.println(m) //代码3] (1)
s =new String(tom,0,3)
System.out.println(s): //代码4] (abc)
catch(IOException e)(]
S1=set(1,2,2,3,3,3,4])
S2={1,2,5,6,4}
Print(s1&s2-s1.intersection(s2))
选项: A:{1,2, 4}
B:set()
C:1,2,2,3,3,3,4]
D:{1,2,5,6,4}
String s2 = "lanqiao";
String s3 = new String("lanqiao");
String s4 = new String("lanqiao");
System.out.println(s1==s2);
System.out.println(s3==s4);
}
}
程序运行后的输出结果是( )
选项: A:true false
C:false false
D:false true
">15.1.有如下程序
public class LanQiao{
public static void main(String] args) {
String s1 = "lanqiao";
String s2 = "lanqiao";
String s3 = new String("lanqiao");
String s4 = new String("lanqiao");
System.out.println(s1==s2);
System.out.println(s3==s4);
}
}
程序运行后的输出结果是( )
选项: A:true false
C:false false
D:false true
}
}
class Rectangle extends Shape {
void display() { //实现抽象类的方法
System.out.println("Rectangle");
}
}
class Triangle extends Shape {
void display() { //实现抽象类的方法
System.out.println("Triangle");
}
}
public class AbstractClassDemo{
public static void main(String args]){
(new Circle()).display();//定义无名对象来调用对应的display方法
(new Rectangle()).display();
(new Triangle()).display();
}
}
输出结果是 ?
">16.阅读程序,给出结果:// AbstractClassDemo.java源代码如下:
abstract class Shape { //定义抽象类Shape和抽象方法display
abstract void display();
}
class Circle extends Shape {
void display() {//实现抽象类的方法
System.out.println("Circle");
}
}
class Rectangle extends Shape {
void display() { //实现抽象类的方法
System.out.println("Rectangle");
}
}
class Triangle extends Shape {
void display() { //实现抽象类的方法
System.out.println("Triangle");
}
}
public class AbstractClassDemo{
public static void main(String args]){
(new Circle()).display();//定义无名对象来调用对应的display方法
(new Rectangle()).display();
(new Triangle()).display();
}
}
输出结果是 ?
c=c/float(a/b)
B:c=c/(int)(a/(float)b)
C:c=(float)c/(a/b)
D:c=c/(int)(a/(float)b)