Huawei's Java interview questions

Source: Internet
Author: User
Huawei's Java interview questions

 

Question No: 1

1. Public class test {

Public static void changestr (string Str ){

STR = "welcome ";

}

Public static void main (string [] ARGs ){

String STR = "1234 ";

Changestr (STR );

System. Out. println (STR );

}

}

Please write the output result:

 

Question No: 2

1. Public class test {

2. Static Boolean Foo (char c ){

3. system. Out. Print (C );

4. Return true;

5 .}

6. Public static void main (string [] argv ){

7. Int I = 0;

8. For (FOO ('A'); Foo ('B') & (I <2); Foo ('C ')){

9. I ++;

10. Foo ('D ');

12 .}

13 .}

14 .}

What is the result?

A. abdcbdcb

B. abcdabcd

C. Compilation fails.

D. An exception is thrown at runtime.

 

Question No: 3

1. Class {

2. Protected int Method1 (int A, int B) {return 0 ;}

3 .}

Which two are valid in a class that extends Class? (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 ;}

 

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 ()

 

Question No: 5

Which method is used by a servlet to place its session ID in a URL that is written 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 () is invoked when a stateful Session Bean instance is passivated.

2. sessioncontext. getrollbackonly () does not throw an exception when a session bean with bean-managed transaction demarcation is activated.

3. An exception is not thrown when sessioncontext. getusertransaction () is called in the afterbegin method of a bean with container-managed transactions.

4. JNDI access to Java: COMP/ENV is permitted in all the sessionsynchronization methods of a stateful session bean with container-managed transaction demarcation.

5. Accessing resource managers in the sessionsynchronization. afterbegin method of a stateful session bean with bean-managed transaction does not throw an exception.

 

 

Part 2: Concept questions

1. Describe the struts architecture? What are the main development tasks of each part?

 

2. What are the explanations and differences of XML?

 

3. What built-in objects and actions does JSP have? What are their functions?

 

4. SQL Q &

Select * from table

And

Select * from table

Where name like '%' and ADDR like '%'

And (incluaddr like '%' or 2_addr like '%'

Or 3_addr like '%' or 4_addr like '% ')

Why are different search results?

 

 

 

5. SQL Q &

Table Structure:

1. Table Name: g_cardapply

Field (field name/type/length ):

G_applyno varchar 8; // application Ticket No. (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 Ticket No. (keyword)

G_name varchar 30; // requester name

G_idcard varchar 18; // requester ID card No.

G_state varchar 2; // Application Status

The joined fields of the two tables are the application form numbers.

Question:

1. query the application date with ID card number 440401430103082

2. query the ID number and number of records with more than two records for the same ID card number

3. Change the application status of the 440401430103082 ID card in both tables to 07.

4. Delete all records surnamed Li in the g_cardapplydetail table

---------------------- ******* Test ******-----------------

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 having count (g_idcard)> = 2;

3. Update g_cardapplied 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 = '000000'; update the g_state of the first table.

Update g_cardapplydetail set g_state = 603 where g_idcard = '000000 ';

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.