One, single choice problem
1. Java is an improved redesign from the () language.
A Ada B. C + +. Pasacal D. BASIC
Answer: B
2. Which of the following statements is correct ()
A Java programs are compiled to produce machine code
B Java programs generate byte code when compiled
C Java programs generate DLLs after they are compiled
D None of the above is correct.
Answer: B
3. The following statements are correct ()
A Constructor in class is not to be omitted
B Constructor must have the same name as class, but the method cannot have the same name as class
C constructor is executed when an object is new
D A class can only define a constructor
Answer: C
4. The package that provides the ability to access the Java database is ()
A java.sql B. java.awt C. Java.lang D. Java.swing
Answer: A
5. The following operation conforms to the method ()
A && B. <> C. If D. :=
Answer: A
6. Execute the following program code
a=0;c=0;
do{
--c;
A=a-1;
}while (a>0);
After the value of C is ()
A 0 B. 1 C. -1 D. Dead loop
Answer: C
7. Which of the following statements is true ()
A The abstract modifier can modify fields, methods, and classes
B The body part of the abstract method must be wrapped in a pair of curly braces {}
C Declaring abstract methods, curly braces are optional
D Declaring an abstract method cannot write curly braces
Answer: D
8. The following statements are correct ()
A Formal parameters can be considered as local variable
B Formal parameters can be decorated by field modifiers
C Arguments that are actually passed when the form parameter is called by the method
D Formal arguments can not be objects
Answer: A
9. Which of the following statements is true ()
A Instance methods can directly invoke instance methods of superclass
B Instance methods can directly call the Superclass class method
C Instance methods can call instance methods of other classes directly
D Instance methods can call the class method of this class directly
Answer: D
Second, multiple choice questions
1. The types of Java programs are ()
A Classes (Class) B. Applet C. Application D. Servlet
2. The following statements are correct ()
A Environment variables can be specified when the source code is compiled
B When compiling a program, the environment variables that you can specify do not include class path
C Javac can compile several Java source files at a time
D Javac.exe can specify which directory the compilation results will be placed in (directory)
Answer: BCD
3. The following identifiers are illegal to have ()
A New B. $Usdollars C. 1234 D. Car.taxi
Answer: ACD
4. The following statements are incorrect ()
A An array is an object
B Arrays belong to a native class
C int number=[]={31,23,33,43,35,63}
D The size of the array can be changed arbitrarily
Answer: BCD
5. cannot be used to modify the interface ()
A Private B. Public C. Protected D. Static
Answer: ACD
6. The following correct have ()
A Call by value does not change the value of the actual parameter
B Call by reference can change the reference address of the actual parameter
C Call by reference cannot change the reference address of the actual parameter
D Call by reference can change the contents of the actual parameter
Answer: ACD
7. The following statements are incorrect ()
A Use this in a class method to invoke the class method of this class
B You can call the class method of this class directly in the class method when you call the
C Only class methods in this class can be called in a class method
D An instance method must not be invoked in a class method
Answer: ACD
8. The following statements are incorrect ()
A Java object-oriented language allows individual processes and functions to exist
B Java object-oriented language allows individual methods to exist
C Methods in the Java language belong to members in a class (member)
D Methods in the Java language must be part of a class (object) and invoke the same method as a procedure or function
Answer: ABC
9. The following statements are incorrect ()
A Java class files that can be successfully run by Java.exe must have a main () method
B J2SDK is the Java API
C Appletviewer.exe can run. jar files with the JAR option
D Java class files that can be successfully run by Appletviewer must have a main () method
Answer: BCD
Third, the judgment question
1. The starting class name in the Java program must be the same as the file name that holds the class. ( )
Answer: Correct
2. Unicode is used to represent a word in 16 digits. ( )
Answer: Correct
3. The data types in the native class can be converted arbitrarily. ( )
Answer: Wrong
(PostScript: I did not think of face test is extraordinary, a lot of questions can not be seen at a glance, at least for me this kind of bird.) For me personally, look at this problem, may be better than to see "Think in Java" is still better, because there are a lot of things, we usually do not care too much, or just understand a little fur, by doing this practice, to their own do not know, unfamiliar knowledge points, Take advantage of this opportunity to properly consolidate. These answers are my own, there are some from the Internet, there is a part of their own, and there is a part of the unfinished, I do not dare to guarantee all right, so please quote, you must check by yourself. Of course, since I can put these answers here, it means I must have tested it myself, and it's not that scary.
Question No:1
Publicclass Test1 {
Publicstaticvoid changestr (String str) {
Str= "Welcome";
}
Publicstaticvoid Main (string[] args) {
String str= "1234";
Changestr (str);
System.out.println (str);
}
}
Output Result: 1234
Although this is a static method, the variable inside is a local variable,
So here is not because it is static method, it is mistaken that the inside variable is also a static variable
Question No:2
Publicclass Test2 {
Staticboolean foo (char c) {
System.out.print (c);
Returntrue;
}
Publicstaticvoid Main (string[] argv) {
int i = 0;
For (65;88&& (I<2); 67)
For (foo (' A '); foo (' B ') && (I < 2); foo (' C ')) {
i++;
Foo (' D ');
}
}
}
Question No:3
1. Class A {
2. protected int method1 (int a, int b) {return 0;}
3.}
Which two are valid in a class of that extends Class A? (Choose two)
A. public int method1 (int a, int b) {return 0;}
B. private int method1 (int a, int b) {return 0;}
C. private int method1 (int A, long b) {return 0;}
D. public short method1 (int a, int b) {return 0;}
E. static protected int method1 (int a, int b) {return 0;}
Publicclass B extends a{
Can not reduce the visibility of the inherited
That is, it is not possible to reduce the visibility of methods that continue from Class A
private int method1 (int a, int b) {return 0;}
This static method cannot hide the instance
Static methods cannot hide instances that inherit from a
static protected int method1 (int a, int b) {return 0;}
The return type is inconsistent with the method in a
public short method1 (int a, int b) {return 0;}
Here is an overloaded method, because the argument type is inconsistent and does not report an error
Privateint method1 (int A, long b) {return 0;}
Visibility can be increased, but cannot be narrowed, correctly
Publicint method1 (int a, int b) {return 0;}
Publicstaticvoid Main (string[] args) {
TODO auto-generated Method Stub
}
}
Question No:4
1. public class outer{
2. public void Someoutermethod () {
3.//Line 3
4.}
5. public class inner{}
6. public static void Main (STRING[]ARGV) {
7. Outer o = new Outer ();
8.//Line 8
9.}
10.}
Which instantiates an instance of Inner?
A. New Inner (); At line 3
B. New Inner (); At line 8
C. New O.inner (); At line 8
D. New Outer.Inner (); At line 8//new Outer (). New Inner ()
The answer is as follows:
Publicclass Outer {
Publicvoid Someoutermethod () {
Line 3
New Inner ()//There's no mistake in here.
}
Publicclass Inner {
}
Publicstaticvoid Main (string[] argv) {
Outer o= new Outer ();
Line 8
O can not be interpreted as a type, error
New O.inner ();
New Outer.Inner ();
New Inner ();
}
}
Question No:5
Which method are used by a servlet to place their session ID in a URL of that's written to the servlet ' s response output stream ?
The servlet is used to place its session ID in a URL that writes to the servlet's response output stream.
A. The Encodeurl method of the HttpServletRequest interface.
B. The Encodeurl method of the HttpServletResponse interface.
C. The Rewriteurl method of the HttpServletRequest interface.
D. The Rewriteurl method of the HttpServletResponse interface.
Question No:6
Which two are equivalent? (Choose two)
A. <%= yoshibean.size%>
B. <%= yoshibean.getsize ()%>
C. <%= yoshibean.getproperty ("size")%>
D. <jsp:getproperty id= "Yoshibean" param= "size"/>
E. <jsp:getproperty name= "Yoshibean" param= "size"/>
F. <jsp:getproperty id= "Yoshibean" property= "size"/>
G. <jsp:getproperty name= "Yoshibean" property= "size"/>
Question No:7
Which of the following statements regarding the lifecycle of a session bean are correct?
1. Java.lang.IllegalStateException is thrown if sessioncontext.getejbobject () are invoked when a stateful session Bean Inst Ance is passivated.
2. Sessioncontext.getrollbackonly () does not throw a exception as session bean with bean-managed transaction Ion is activated.
3. A exception is isn't thrown when sessioncontext.getusertransaction () was called in the Afterbegin method of a beans with C ontainer-managed transactions.
4. JNDI access to java:comp/env are permitted in all sessionsynchronization methods of a stateful session beans with con tainer-managed transaction demarcation.
5. Accessing resource managers in the Sessionsynchronization.afterbegin method of a stateful session beans with Bean-manage D transaction does not throw a exception.
Part II: Concept questions
1. Describes the struts architecture. The main parts of the development work to include which.
Struts is an implementation of MVC, which uses the servlet and JSP tags (which belong to the Java EE Specification) as part of the implementation. Struts inherits the characteristics of MVC and makes corresponding changes and extensions according to the characteristics of Java EE. The architecture and working principle of struts are shown in Figure 2 below:
1) models (model)
In the architecture of struts, the model is divided into two parts: the internal state of the system and the operation that can change the state (transaction logic). The internal state is usually represented by a set of actinform beans. Depending on the design or application complexity, these beans can be self-contained and have a persistent state, or obtain data only when needed (from a database). Large applications typically encapsulate transaction logic (operations) within a method, which can be invoked by a bean that owns state information. A shopping cart bean, for example, has information about the user's purchase of the product, and possibly a checkout () method to check the user's credit card and send a shipping order to the warehouse. In a small program, operations may be embedded in the action class, which is part of the controller role in the Struts framework. This approach works well when logic is simple. It is recommended that the user separate the transaction logic (what to do) from the role that the Action class plays (deciding what to do).
2) Views (view)
The view is built primarily by JSP, and struts contains the extended Custom tag library (TAGLIB), which simplifies the process of creating a fully internationalized user interface. The current tag library includes: Bean tags, HTML tags, Logic tags, Nested tags and template tags and so on.
3) Controller (Controller)
In struts, the basic controller component is the instance Servelt in the Actionservlet class, and the actual servlet used in the configuration file is defined by a set of mappings (described by the Actionmapping Class). The operation of the business logic is mainly coordinated by the actions, actionmapping, and Actionforward components, in which the action acts as the real implementation of the business logic, Actionmapping and Actionforward specify the direction in which different business logic or processes are run. Struts-config.xml file Configuration controller.
2. XML includes which interpretation techniques, and what the difference is.
Includes the DOM (Document object Modal) Documentation Objects model, SAX (simple APIs for XML). Dom is a one-time read the entire document into memory operations, if the document is relatively small, read into memory, can greatly improve the speed of operation, but if the document is relatively large, then this is laborious. So at this point in the Sax application, it's not a one-time thing to read the entire document into memory, which is much easier to do with large documents.
3. What built-in objects and actions are in the JSP. What are their roles, respectively.
There are 9 basic built-in components of JSP:
Request client, this request contains parameters from the Get/post request
Response Web page Returns the response of the client
The properties of the PageContext Web page are managed here
Session duration associated with the request
What the application servlet is doing
Out output used to transmit a response
Config servlet frame part
Page JSP pages themselves
Exception for error pages, not captured exceptions
Common components: request, response, out, session, application, exception
4. SQL question and Answer question
SELECT * from TABLE
And
SELECT * from TABLE
WHERE NAME like '%% ' and ADDR like ' percent '
and (1_addr like '% ' OR 2_addr like '% ')
Or 3_addr like '% ' or 4_addr like ' percent ')
Why the search results are different.
For:
I did a test, in Access, with its query, this will and in MySQL to get different results, you may wish to try, I was in Access yesterday with SQL query, the result is empty, that is, there is no record; and in MySQL, the condition is empty records do not show, The rest is shown.
5. SQL question and Answer question
Table structure:
1, table name: g_cardapply
Field (field name/type/length):
G_applyno varchar 8;//application number (keyword)
G_applydate bigint 8;//Application Date
G_state varchar 2;//Application Status
2, table name: G_cardapplydetail
Field (field name/type/length):
G_applyno varchar 8;//application number (keyword)
G_name varchar 30;//Applicant Name
G_idcard varchar 18;//Applicant ID Number
G_state varchar 2;//Application Status
Where the two-table Association field is the requisition number.
Topic:
1. Check the date of application for ID number 440401430103082
Select g_cardapply.g_ applydate from G_cardapply, g_cardapplydetail where g_cardapplydetail.g_idcard= ' and g_ Cardapply.g_applyno=g_cardapplydetail.g_applyno
2, check the same ID number has more than two records of ID number and number of records
3. The application status of 440401430103082 Records of ID card number in two tables is changed to 07.
Update g_cardapply. G_state= ' modified ', G_cardapplydetail. g_state
4. Delete all the records of the surname Lee in the G_cardapplydetail table
------------------------the test of Hu Jintao-----------------
Create DATABASE Mianshi
Use Mianshi;
CREATE TABLE G_cardapply (
G_applyno varchar (8),
G_applydate bigint,
G_state varchar (20)
)
Go
CREATE TABLE G_cardapplydetail (
G_applyno varchar (8),
G_name varchar (30),
G_idcard varchar (18),
G_state varchar (20)
)
1. Select A1.g_applydate from g_cardapply as A1 inner join G_cardapplydetail A2 on
A1.g_applyno=a2.g_applyno where a2.g_idcard= "123";
2. Select G_idcard,count (g_idcard) from G_cardapplydetail
GROUP BY G_idcard has count (G_idcard) >=2;
3, update g_cardapply set g_state=603 from g_cardapply as g_d inner join G_cardapplydetail as G_c on
G_d.g_applyno=g_c.g_applyno and g_idcard= ' 123 '; update the g_state of the first table
Update G_cardapplydetail set g_state=603 where g_idcard= ' 123 ';
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service