SAIC Pen Test

Source: Internet
Author: User

First, the Java EE (total 20 points. 2 points per question)

    1. Describes the differences between string and StringBuffer.

String to manipulate a string of characters. Immutable. Once created, it is not possible to modify its value.

StringBuffer is also an operation on a string of characters, but a mutable class.

    1. What is the difference between a run-time exception (runtimeexception) and a generic exception?

General exceptions are available for capture. A run-time exception is an unpredictable exception.

    1. What is the difference between Sleep () and wait ()?

Sleep is a thread-class method that causes this thread to pause execution for a specified time, giving the execution opportunity to other threads, but the monitoring state remains and is automatically restored after that time. Calling sleep does not release the object lock.
Wait (). Locks are released

    1. There are several ways to implement multithreading?

Three species, 1. Inheriting the thread class, overriding the Run function

2. Implement the Runnable interface and rewrite the run function

3. Implement the callable interface, overriding the Call function

    1. Describes the relationship between the basic state of a thread and its state.

The Thread.threadstate property provides a bitmask that indicates the current state of the thread. A thread is always at least one possible state in the ThreadState enumeration and can be in multiple states at the same time.

Once a thread leaves the unstarted state because it calls Thread.Start, it will never be able to return to the unstarted state. Similarly, threads can never leave the Stopped state.

    1. What is thread synchronization, how do I implement thread synchronization?

When two or more threads need access to the same resource, they need to be in a certain order to ensure that the resource is only used by one thread at a time, called synchronization. For synchronization to work, you must obtain a lock on each thread object. Obtaining it guarantees that only one thread accesses the shared key code in the object at the same time, and that the other thread cannot enter the shared code until the lock is released. At this point, if there are other threads that want to get the lock on the object, they have to wait in the waiting queue. The lock is freed when the thread that owns the object's lock exits the shared code, waiting for the first thread in the queue to get the lock, thus entering the shared code area.

    1. What is the difference between forward and redirect in a JSP or servlet?

Forward is the server internal redirect, the program receives the request redirects to another program, the client does not know, redirect is the server receives the request to send a state header to the customer, the customer will request again, here more two times the network communication intercourse. Redirect is sent to the client again after request, so the data is not retained.

    1. Briefly describes the basic steps of the JDBC call database.

1, load Driver
2, create the connection
3, gets the statement object
4, Execute SQL statement
5, if it is a query, you can also use the result set
6, close the connection
7. Catching and Handling exceptions

    1. Describes the life cycle of the servlet.

After the servlet is instantiated by the server, the container runs its Init method, the service method is run when the request arrives, and the service method automatically dispatches the Execute method (Doget,dopost) corresponding to the request, etc. The Destroy method is called when the server decides to destroy the instance.

Second, algorithm (total 20 points)

    1. Please list several sorting algorithms and use Java to implement a fast sorting algorithm. (6 points)

Bubble sort, quick sort, shaker sort, heap sort.

public void Quick (integer[] str) {

if (str.length > 0) {//See if the array is empty

_quicksort (str, 0, str.length-1);

}

}

public void _quicksort (integer[] list, int. Low, int.) {

if (Low < high) {

int middle = getmiddle (list, low, high); Divides a list array into a split

_quicksort (list, low, middle-1); Recursive ordering of low-word tables

_quicksort (list, middle + 1, high); Recursive ordering of high-character tables

}

}

public int getmiddle (integer[] list, int. Low, int.) {

int tmp = List[low]; The first of the arrays as a middle axis

while (Low < high) {

while (Low < high && List[high] > tmp) {

high--;

}

List[low] = List[high]; Less than mid-axis records moved to the low end

while (Low < high && List[low] < tmp) {

low++;

}

List[high] = List[low]; A record larger than the middle axis moves to the high end

}

List[low] = tmp; Middle axis record to tail

return low; Returns the position of the middle axis

}

    1. Using Java to implement two-fork tree pre-sequence traversal, middle sequence traversal and post-order traversal. (8 points)

Publicclass Tree {

private int data;//Data node
Private Tree left;//Zuozi
Private Tree right;//right subtree

public Tree (int data) {
This.data = data;
This.left = null;
This.right = null;
}

/**
* Create a two-fork tree and return to the root node.
*/
public static Tree Createtree (int[] input) {
Tree root = null;
Tree temp = null;
for (int i = 0; i < input.length; i++) {
Creating the root node
if (root = = null) {
Root = temp = NewTree (Input[i]);
} else {
Back to the root node.
temp = root;
Adding nodes
while (temp.data!= Input[i]) {
if (Input[i] <= temp.data) {
if (temp.left! = null) {
temp = Temp.left;
} else {
Temp.left = NewTree (Input[i]);
}
} else {
if (temp.right! = null) {
temp = Temp.right;
} else {
Temp.right = NewTree (Input[i]);
}
}
}
}
}
return root;
}

/**
* Pre-sequence traversal
*/
public static void preorder (tree tree) {
if (tree! = null) {
System.out.print (Tree.data + "");
Preorder (Tree.left);
Preorder (tree.right);
}
}

/**
* Middle Sequence traversal
*/
public static void Midorder (tree tree) {
if (tree! = null) {
Midorder (Tree.left);
System.out.print (Tree.data + "");
Midorder (Tree.right);
}
}

/**
* Post-sequential traversal
*/
public static void Posorder (tree tree) {
if (tree! = null) {
Posorder (Tree.left);
Posorder (Tree.right);
System.out.print (Tree.data + "");
}
}

/**
* Find the depth of the binary tree
*/
public static int Length (tree tree) {
int depth1;
int depth2;
if (tree = = null) return 0;
The depth of Zuozi
depth1 = Length (tree.left);
The depth of the right sub-tree
Depth2 = Length (tree.right);
if (depth1>depth2)
return depth1+1;
Else
return depth2+1;
}
public static void Main (string[] args) {
Int[] input = {4, 2, 6, 1, 3, 5, 7,8,10};
Tree tree = createtree (input);
System.out.print ("Pre-sequence Traversal:");
Preorder (tree);
System.out.print ("\ n sequence traversal:");
Midorder (tree);
System.out.print ("\ n post-post traversal:");
Posorder (tree);
}
}

    1. Read the code and answer the question (6 points)

Public String listtostring (Vector strlist) {

String str = new string ();

SortedSet set = new TreeSet ();

Set.addall (strlist);

For (Iterator iter=set.iterator (); Iter.hasnext ();

String currstr = (string) iter.next ();

Str + = Currstr + ";";

}

return str;

Question 1:

What does this piece of code do? If the input list {"To", "SAIC", "Welcome"}, what is the input result?

array element concatenation. The treeset is stored alphabetically, with the result: SAIC; to; Welcome;

Question 2 is there any place in this code that is wrong or can be improved?

Error: for (Iterator iter=set.iterator (); Iter.hasnext (), missing "at the back)"

Improvement: Stitching to the end, the last semicolon should be removed.

Three, the design pattern (total score 10 points, each question 5 points)

    1. Programming Implementation Design pattern: Singleton (singleton mode).

Classsingleton {
private static Singleton s;
Private Singleton () {
}
public static Singleton Getsigleton ()
{
if (s==null) s=new Singleton ();
return s;
}
}

    1. Draw a UML class diagram of an abstract factory (Factory).

Iv. database (total 20 points)

    1. The difference between the left outer join, the right outer join, the full outer join, the inner join of the SOL query statement.

The result set for the left outer join includes all rows from the left table specified in the outer clause, not just the rows that match the join column

The right outer join is a reverse connection of the left outward connection. All rows of the right table will be returned.

The full outer join returns all rows from the left and right tables. When a row does not have a matching row in another table, the selection list column for the other table contains a null value. If there are matching rows between the tables, the entire result set row contains the data values of the base table.

An inner join uses a comparison operator to match rows in two tables based on the values of the columns that are common to each table.

    1. Illustrate the meaning and use of GROUP BY and having clauses.

How many people in each department are going to use GROUP by
Select DepartmentID as ' department name ',
COUNT (*) as ' number ' frombasicdepartment GROUP by DepartmentID

Displays the total area of each region. Only those areas with more than 1000000 area are shown.

SELECT region, SUM (area)

From BBC

GROUP by region

Have SUM (area) >1000000

    1. Difference between in and exists (4 points)

For example in (IS) = 1 or = 2 A simple way of writing, so generally in the case of fewer elements to use in, if more than a exists to specify a subquery.

    1. Writing SQL statements

To manage the job training information, set up 3 tables.

S (S#,SN,SD,SA) S#,sn,sd,sa respectively represents student number, student name, affiliation unit, student age

C (C#,CN) C#,CN represents the course number, the course name, respectively.

SC (S#,C#,G) S#,c#,g respectively represents the student number, the course number, the academic achievement

Issue 1: Use standard nested SQL statements to query the student number and name of the elective course named "Tax base".

Select

SSC s#, SSC.SN

From c

Left Join

(Select s.*,sc.c#

From SC

Left JOIN S

On s.s#=sc.s#

) as SSC

On ssc.c#=c.c#

Where c.cn= ' tax base '

Question 2: The enquiry of the elective course is "C2" of all students of the student's number, name, unit, performance, and in accordance with the Unit ascending, the grade descending order.

Select SC.C#,S.SN,S.SD,SC.G

From SC

Left JOIN S

On s.s#=sc.s#

where c. c#= ' C2 '

ORDER BY S.sdasc,sc.g.desc

Question 3: Check the number of elective courses for all learners, list the number of students, name, selected courses, and arrange them in descending order of the number of courses.

SELECTSC.S#,S.SN, Sc.count

(

Select COUNT (s#) as count,s#

From SC

GROUP BY sc.s#

) SC

Left JOIN S

On s.s#=sc.s#

Order Bysc.count DESC

Question 4: Query the number of elective courses more than 5 times the student's number, name, unit, number of courses selected, and in ascending order by number.

SELECT

s#,

SN,

Sd

(SELECT COUNT (DISTINCT C #) Fromsc

Where s#=s. s#

) as Count

From S

WHERE s# in (

SELECT [s#] from SC

GROUP by [s#]

Having COUNT (distinct[c#]) >5)

V. Framework (total 30 points)

Jsf

    1. Take JSF as an example to describe the MVC design pattern.
    2. Brief description of JSF request processing three life cycle

1. Restore the View
2. Apply the requested value; process validation
3. Updating model values; handling events
4. Invoking the program; handling events
5. Responding; handling events

    1. What does the backing Bea in JSF do?

The backing bean defines the properties and processing logic of the UI component on the page. The properties of each backing bean correspond to the values of a component or component. The backing Bean also defines a set of methods for performing component functions, such as validating the data of the component, handling events triggered by the component, and handling navigation-related operations when the component is activate.

    1. What does the converter in JSF do?

Input transformations: Transform user input values when user commits

Output transform: The display value is transformed before the screen is displayed

    1. What does the validator in JSF do?

Validates the data entered by the user.

    1. Brief description of Value-change events, Action events, Data mooelevents, Phase events.

Value change events, action events, data Model events, stage events

    1. The six stages of JSF Request processinglifecycle.

Reply screen (Restore View)

Apply Request value (apply request values)

Perform validation (Process validations)

Updating the model value (update models values)

Evoke an application (Invoke application)

Draw Response (Render Response)

    1. What does the immediate attribute of CommandButton do?

After the JSF view component obtains the value that is obtained in the request, it processes the specified event immediately, instead of the subsequent process of converter processing, validator processing, updating model values, and so on.

    1. Use of

The encapsulated component is viewed as a component

    1. Use of <f:verbatim>

If you want to put non-JSF components, such as simple template text, you need to use the <f:verbatim/> tag for processing.

Spring

    1. Briefly describes the basic concepts of Dependency injection (Dependency injeciton,di) and control inversion (INVERSIONOFCONTROL,IOC).

Dependency Injection di is a programming pattern and architecture model, sometimes referred to as inversion of control, although, technically, dependency injection is a special implementation of IOC, dependency injection refers to an object applying another object to provide a special ability, For example, a database connection is passed to an object's structure method instead of creating a connection within that object itself. The basic idea of control inversion and dependency injection is to convert class dependencies from inside the class to the outside to reduce dependency
Applying control inversion, when an object is created, it is passed to it by an external entity that regulates all objects within the system, and references the object to which it depends. It can also be said that the dependency is injected into the object. So, control reversal is a reversal of this responsibility about how an object obtains a reference to the object he relies on.

    1. Briefly describes the basic concepts of AOP (Advice, Joinpoint, Polntcut, Aspect) and the features and limitations of implementation in spring AOP.

Advice: Used to define interception behavior

Joinpoint: Provides access to the target object, proxy object, method parameter, and other data of the currently notified method

Polntcut: Captures all connection points in the specified method execution, including the execution method itself

Aspect: Pointcut indicator is used to indicate pointcut expression purpose.

    1. What does Spring autorwiring by name and autowiring by type mean?

Bytype is to find the object named "Myidprovidermanager" in the "Myidprovidermanager" class by type, and then inject it
ByName is found by name.

SAIC Pen Test

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.