Daily java small problem (a)

ABC class is defined as follows:

1 . public class ABC{

2 . public double max( double a, double b) { }

3 .

4 . }

Which of the following methods to insert the line 3 is not legitimate. ()
Public a float max (a float A, a float B, a float C) {}
public Double max (Double C, Double D) {}
public a float max (a float A, a float B) {}
Private int max (int A, int B , int c) {}

The answer is: B
Cause: The method's parameter list is not the same need for heavy-duty requirements (number, type or parameters), change their name or modify the return value and there is no access and use

java one-dimensional array initialization

There are two one-dimensional Java array initialization method
1, static initialization

int array [] = new int [ ] {1,2,3,4,5}
, or

int array [] = {1,2,3,4,5}
Note that the error is written in the form

Array int [] = new new int [. 5] {1,2,3,4,5}
2, dynamic initialization

int array[] = new int[5];

It is known as the command java MyTest abc tell me which statement is correct? ()

The correct answer: CD
args [0] = "abc MyTest"
args [0] = "MyTest"
args [0] = "A"
args [1] = "b"

Analysis: For the java command, after the class name is an array, so for java mytest abc considered the argument passed a string array. I.e. args [0] = a args [1] = b args [2] = c

JavaScript Object of history

length: Returns the url in the browser history list number
back () to load a URL before the history list.
forward () to load history list next URL.
go () to load a specific page history list.

There are types of Java programs:

(A) embedded in Web documents, _Applet by the browser to watch

(B) independently operated Application

(C) the server Servlets

The following right there ()

The correct answer: ACD your answer: AC (error)
Call by value will not change the value of the actual parameters of
call by reference can change the actual parameter reference address
call by reference can not change the address of the actual reference parameters of
call by reference can change the actual parameters content

Analysis: Basic type 1 and type variables are used as basic parameter passed to the method, the value is passed.
In the process entity, it can not be re-assigned to the original variables, can not change its value.
2 and referenced variables are passed as arguments to the method, a reference.
In the process entity, it can not be re-assigned to the original variables, but you can change the properties of an object it points

There are several common relations between classes:

The correct answer: ABC Your answer: ACD (error)
"the USES-A" relationship
"HAS-A" relationship
"IS-A" relationship
"INHERIT-A" relationship

user-a (dependent)
has-A (composition)
IS-A (inherited)

() Of the difference between java and wait method sleep () method:

  1. These two methods are from different classes Object and Thread
  2. The method is not the most important sleep release the lock, the lock release wait method, so that the thread can use sensitive word sync block or control method.
  3. wait, notify, and notifyAll only synchronous or a synchronous control method for use inside the control block, and sleep can be
    used anywhere in
    the synchronized (X) {
    x.notify ()
    // or the wait ()
    }
  4. sleep must catch the exception, and wait, notify and notifyAll do not need to catch the exception

The following code defines a variable, and how the output value of this variable?

正确答案: A C D
A.<% String myBean = (String)pageContext.getAttribute(“stringBean”,PageContext.PAGE_SCOPE);
%>
<%=myBean%>
<bean:write name=“helloworld”/>
<bean:write name=“stringBean”/>
<%=stringBean%>

Parsing:
A Options:
Gets the value stringBean by pageContext (example PageContext class provides access to the JSP page for all objects and namespaces), assigned to the variable of type String myBean, and then deal with the value by Jsp expression.
bean: define
the title of the Struts bean: define tag defines a string variable stringBean, its value helloworld.
the bean: Write
the bean: Write equivalent <% = request.getAttribute ( "something" )%> where something is the name of the attribute. So wrong B, C right.
Option D:
Gets the value of the variable stringBean by Jsp expression

Published 36 original articles · won praise 11 · views 10000 +

Guess you like

Origin blog.csdn.net/s_xchenzejian/article/details/97975495