单项选择题
类Student的声明如下:
package com.school class Student{ String name;
int age;
Student(String name,int age){
//code } void study(String subject){ /
/code } }
正确调用方法study(String subject)的是哪项?()
A.Student stu = new Student(“Tom”,23); stu.study(“数学”);
B.Student.study(“数学”);
C.Student stu = new Student(“Tom”,23); stu.study();
D.Student stu = new Student(“Tom”,23); String result=stu.study(“数学”);
相关考题
-
单项选择题
import java.io.PrintWriter; class DoFormat { public static void main(String [] args) { int x = 42; int y = 12345; float z = 7; System.out.format("-%4d- ", x); System.out.format("-%4d- ", y); System.out.format("-%4.1d- ", z); } } 结果为:()
A.编译失败
B.-42- -1234- -7.0-
C.- 42- -1234- - 7.0-
D.运行时异常被抛出 -
单项选择题
class ThreadBoth extends Thread implements Runnable { public void run(){ System.out.print("hi "); } public static void main(String [] args){ Thread t1 = new ThreadBoth(); Thread t2 = new Thread(t1); t1.run(); t2.run(); } } 结果为:()
A.hi
B.hi hi
C.编译失败
D.代码运行,但无输出结果 -
单项选择题
假设在目录myprj/src/school中有Java源文件Student.java,如果希望该文件编译后的类文件出现在目录myprj/classes/school中,应该使用下列哪一个命令?()
A.cd myprj/src javac –d ../classes school/Student.java
B.cd myprj/src javac ../classes school/*.java
C.cd myprj javac –d ../classes school/*.java
D.cd myprj/src/school javac –d ../classes school/Student.java
