作业帮 > 综合 > 作业

一些JAVA问题,初学者需要讲解?

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/23 15:00:46
一些JAVA问题,初学者需要讲解?
1.Programming involves four general phases that the programmer moves into and out of during the development of a program. The order in which the programmer moves through these phases is generally which of the following?
(a) There is no defined order. The programmer moves into and out of one of the various four phases as dictated by circumstance and situation while writing the program.
(b) planning --> redefining--> coding--> testing
(c) defining/redefining --> planning --> implementing/coding --> testing/analyzing
(d) planning --> coding --> testing --> analyzing
(编程的一般步骤是怎么样的?)
2.Valid Java comments include which of the following?
I. /* this is an /* embedded */ comment */
II. /* this is an // embedded // comment */
III. // this is a comment */
(a) I only
(b) I and II only
(c) I and III only
(d) II and III only
(注释的规则有哪些?)
3.Consider a Java servlet that is invoked upon the submission of a form. If the form contains a radio button control with the name Foo, which of the following lines of code in the servlet can retrieve the value of this radio button?
(a) request.getRadio("Foo");
(b) request.getFoo();
(c) request.getParameter("Foo", radio);
(d) request.getParameter("Foo");
4.In a Java servlet, which of the following lines can cause data that was input by a user into an HTML form to be retrieved?
(a) response.setContentType("text/html");
(b) response.getWriter();
(c) out.println("Form value");
(d) request.getParameter("Name");
3和4在调用方法是有什么异同?
5.Consider the following Java code fragment.
public class TrafficLight{
int status;
public void changeStatus(int newStatus) {
status = newStatus;
}
public void turnOn(int newStatus) {
// . . .
}
}
In the method turnOn, which of the following statements should be used to call method changeStatus?
(a) changeStatus.newStatus;
(b) changeStatus(newStatus);
(c) TrafficLight.changeStatus(newStatus);
(d) changeStatus(TrafficLight, newStatus);
注:5中先TrafficLight的类,然后定义了叫changeStatus和turnOn的方法,那么要调用changeStatus的方法应该是C啊,为什么是B直接调用.比如6题调用方法时就是br.readLine();
6.If variable br references an instance of the class java.io.BufferedReader, which of the following statements is a legal call to the method readLine of the class?
(a) br.readLine;
(b) br(readLine);
(c) readLine(br);
(d) br.readLine();
我们的教材都是英文的啊,我也看得头大啊.
回复三楼:不是NIIT,我是大一的,我们的教材是英文的,作业也是英文的.
NIIT?
1.C
2.D (copy the comments to eclipse and then you will find the answer.)
3.D
4.D
5.B The right answer is this---this.changeStatus(newStatus);
6.D
Just FYI, and also i'm not sure the correctness.
And English is also very important.