Mogujie.com 2015 school recruit Java Development pen exam details, 2015 java

Source: Internet
Author: User

Mogujie.com 2015 school recruit Java Development pen exam details, 2015 java

1. Which of the following statements about processes and threads is true ()

A. All threads in the parent process share the same address space, and all child processes of the parent process share the same address space.

B. Changing the status of the main thread in the process will affect the behavior of other threads. Changing the status of the parent process will not affect other sub-processes.

C. multithreading can cause deadlocks, but multi-process won't.

D. None of the above.

Resolution: A indicates that the process has an independent address space. B indicates that there is no dependency when the main thread and sub-thread are in parallel. In the parent process and child process, the child process is a copy of the parent process. After the child process is created, the child process has its own space, copy the data of the parent process to the space of the child process. The system determines who runs the program first. C errors, multithreading, and multi-process will lead to deadlocks. Generally, deadlocks refer to deadlocks between processes.

The main difference between processes and threads is that they are different operating system resource management methods. A process has an independent address space. After a process crashes, it will not affect other processes in the protection mode, but the thread is only a different execution path in the process. A thread has its own stack and local variables, but there is no separate address space between threads. If a thread dies, the whole process dies. Therefore, multi-process programs are more robust than multi-threaded programs, however, during process switching, resources are consumed and the efficiency is lower. But for some concurrent operations that require simultaneous and shared variables, you can only use threads, not processes. If you are interested, I suggest you take a look at the modern operating system or the design and implementation of the operating system. Make it clear about the problem.

2. The common data structure used to create indexes in the database is ()

A. One-way linked list B. Stack C. B + tree D. Queue

Resolution: an index sorts records by multiple fields. Index a field in the table creates another data structure, which stores the value of the field, and each value points to its related records. The data structure of this index is sorted, so binary search can be performed on it. The disadvantage of indexing is that it occupies additional disk space. Because the index is stored in the database, if you create an index for many fields in the same table, the file may quickly expand to the upper limit specified by the file system.

During the use of the database system, data query is the most frequently used data operation. The most basic query algorithm is linear search, which traverses the table and matches the row-by-row match to determine whether the value is equal to the keyword to be searched. the time complexity is O (n ). However, tables with low time complexity of O (n) algorithms and databases with low load can also have good performance. However, when the data increases, the time complexity of the O (n) algorithm is obviously bad, and the performance will soon decline. Fortunately, the development of computer science provides many better search algorithms, such as binary search and binary tree search. If you perform a slight analysis, you will find that each search algorithm can only be applied to a specific data structure. For example, binary search requires that the retrieved data be ordered, while binary search can only be applied to binary search trees, however, the organizational structure of the data itself cannot fully satisfy all kinds of data structures (for example, theoretically it is impossible to organize both columns in order at the same time, the database system also maintains data structures that meet specific search algorithms. These data structures reference (point to) data in some way, so that advanced search algorithms can be implemented on these data structures. This data structure is an index. An index is a structure that sorts the values of one or more columns in a database table. Compared to searching all rows in a table, indexes use pointers to the data values stored in the specified column in the table, and sort these pointers in the specified order to help you get information faster. Generally, an index must be created on a table only when data in the index column is frequently queried. Indexes occupy disk space and affect the data update speed. However, in most cases, the data retrieval speed advantage brought by indexes greatly exceeds its shortcomings. Currently, most database systems and file systems use B-Tree or its variant B + Tree as the index structure.

3. Four employees from mogujie.com. The probability that at least two people share the same zodiac sign is ()

A.41/96 B .55/96 C.72/128 D.90/128

Resolution: P (A) = 1-12*11*10*9/12 ^ 4 = 41/96.

4. mogujie.com is a young and dynamic company with 500 employees. Xiaoxia (male employees) is honest and reliable, and only tells the truth. The little immortals (female employees) are naughty and cute. They only say false things. One day, when a customer came to visit the company, he asked the company's employees, how many of your company's immortals do you have? The employees of the Company answered one by one enthusiastically. The first employee said one, and the second employee said two... 500th employees said five hundred. How many immortals does mogujie.com have?

A.1 B .250 C.499 D.500

Resolution: first, only one employee may be right. Others are wrong. It is impossible for both people to be right. There is only one man, and the remaining 499 are women.

5. Is the IP address 131.53.12.71 A () IP address?

A. a B. B C. C D. D

Resolution: The IP address range of the-type network is 1.0.0.1-127.255.254, the IP address range of the B-type network is 128.1.0.1-191.255.255.254, And the IP address range of the C-type network is 192.0.1.1-223.255.255.254. The Class A address is characterized by the first binary number of the network identifier. The value must be "0 ". Therefore, the CIDR block number ranges from 127 to, followed by the specific host number allocation.

 

6. If a system 12*5 = 104 is set up, what is the system using () hexadecimal?

A.6 B .7 C.8 D.9

7. Implement a function by programming. The input is a given string consisting of English words, and the output is reversed in the order of English words. For example, if the given string is "hi welcome to mogujie", the output is "mogujie to welcome hi "?

 

public class InterruptString {    public static void main (String args[]){        String str = "hi welcome to mogujie";        for(int i = inverse(str).length - 1; i >= 0 ; i--){            System.out.print( inverse(str)[i]+" ");        }    }public static String[] inverse(String str){        String strArray[] = str.split(" ");    return strArray;}}

 

8. Enter an integer array. The array contains both positive and negative numbers. One or more consecutive integers in the array form a sub-array, and each sub-array has a sum. Returns the maximum value of the sum of all sub-arrays. The time complexity is O (n ). For example, if the input number is 1,-, 10,-, 2,-5, and the maximum sub-array is 3, 10,-, 2. and 18.

public class SonArray {    public static void main(String args[]){        Integer[] arrayIntegers = {1,-2,3,10,-4,7,2,-5};        String[] str = sonArray(arrayIntegers).split(" ");        System.out.println("The Big Sum is:" + str[0]);            }    static String sonArray(Integer[] array){        int sum = 0, max = 0;        for(int i = 0; i < array.length; i++){            sum += array[i];            if(sum < 0){                sum = 0;            }            max = sum > max?sum:max;        }        return max+" ";    }}

9. Given a string (an English paragraph), the user enters a word, calculates the total number of times that the word appears, and the position at which it appears.

// The Java language is compiled first and then executed

Import java. util. ArrayList;


Public class DivString {
Public static void main (String args []) {
String str = "I love china I china love xu ";
String strArray [] = str. split (str );
ArrayList <String> arrayList = new ArrayList <String> ();
For (int I = 0; I <strArray. length; I ++ ){
If (strArray [I])
ArrayList. add (strArray [I]);
}
}

}

 

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.