Android Engineer Test-2015-waveguide company, Android-2015 --
1. One of the advantages of using interrupt methods in micro-computers is (C)
2. Which of the following data is the type of Virtual Machine Used in j2s? (C)
A. JVM (Java Virtual Machine)
B. DVM
C. CVM (or KVM)
D. Card VM
3. The following main differences between the CLDC1.1 core class library and J2SE core class library are: ()
A. Thread groups or daemon threads are not supported.
B. The floating point data type is not supported.
C. Weak references are not supported.
D. Limited Error Handling
4. Which of the following program fragments inserts a node in the center of the linked list. (Assume that the NEW node is NEW and you want to insert it after the Pointer node) (C)
A. NEW-> next = Pointer; Pointer = NEW
B. NEW-> next = Pointer-> next; Pointer-> next = NEW
C. Pointer-> next = NEW-> next; NEW-> next = Pointer
D. None of the above
5. Which of the following statements about abstract classes are true? ()
A. Abstract constructor cannot be generated.
B. Abstract static methods can be generated.
C. Allow generation of private Abstract METHODS
D. All of the above descriptions are true.
6.a PNG image file with a width of 70 pixels and a height of 20 pixels is used to create Spirte. The program is as follows. Which of the following statements is true? D
Image img;
Try {img = Image. createImage ("/a.png ");
} Catch (Exception e ){}
Sprite sprite = new Sprite (img, 20, 20 );
A. The image is divided into three pictures by A ratio of 20 pixels in width and 20 pixels in height.
B. The image is divided into 20 pixels in width and 20 pixels in height.
C. The image is used by the Sprite and depicts the Sprite image to the position of the screen coordinate (20, 20.
D. Exceptions
7. Which of the following methods can render a dotted line on the screen?
Public void paint (Graphics g)
{
G. setColor (255,255,255 );
G. fillRect (0, 0, getWidth (), getHeight ());
/* Code segment */
G. setColor (255, 0, 0 );
G. drawLine (20, 20,100, 20 );
/* Code segment B */
G. setColor (125,125,125 );
G. drawLine (20, 25 );
G. setStrokeStyle (Graphics. SOLID );
/* Code segment C */
G. setColor (125,125,125 );
G. drawLine (20, 30 );
G. setStrokeStyle (Graphics. DOTTED );
/* Code segment D */
G. setColor (255,255,255 );
G. drawLine (20, 50 );}
A. Code segment a B. Code segment B C. Code segment C D. Code segment D
Answer: C
8. Both Bluetooth and 802.11b are short-range communication technologies. Which of the following statements is false? (D)
A. Bluetooth and 802.11b are both wireless technologies and both use A GHz spectrum.
B. 802.11b is mainly used to connect large devices with power consumption, such as personal computers and laptop computers.
C. Bluetooth is mainly used to connect small devices with small electrodes, such as PDAs and mobile phones.
D. The data exchange speed of Bluetooth Technology reaches 11 Mb/s, and the distance is up to 100 meters.
9. The following is an example of using the Timer class and the TimerTask class to implement the thread (the design of other code and classes is omitted), to determine what functions the following code can implement: (B)
Timer timer = new Timer (); // generates an object of the Timer class
TimerTask tT = new timerTask (); // This class inherits the TimerTask class
Timer. schedule (tT, 100,100 0 );
A. Wait 1 second after the program starts, and run the run () method of the TimerTask class once every 100 milliseconds.
B. wait 100 milliseconds after the program starts, and run the run () method of the TimerTask class once every one second.
C. Wait 10 seconds after the program starts, and run the run () method of the TimerTask class once every 1000 milliseconds
D. Wait 1 second after the program starts, and run the run () method of the TimerTask class once every 10 seconds.
10. Which of the following statements about how to use J2SE are correct? _ C __
A. g. getFont ("SansSerif"); used to obtain the current font, without Parameters
B. g. erase (x, y, w, h); // clear the rectangle at (x, y ).
C. Font f = new Font ("serif", Font. BOLD, 12 );
D. g. setColor (Color. Yellow); // set the current Color to Yellow
11. The architecture of J2EE includes B.
A. Java language, Java editor, and Java Virtual Machine
B. Configuration, Profile, and optional packages
C. CLDC, MIDP, WMA
D. CDC, Profile, and optional packages
12. In Java, multiple threads are created using the (B D) method.
A. Implement the Run Interface
B. Implement the Runnable interface
C. inherit the Pocess class and implement the run () method
D. inherit the Thread class and implement the run () method
13. D
14. In MIDP, which of the following methods are involved in Code Synchronization? (BC)
A. Use global variables
B. Use the callSerially Method
C. Use the synchronized keyword, including
D. Use servicePaint
15. The operating system provides process management, storage management, file management, and device management functions. Which of the following statements is incorrect? ().
A. Process Management is mainly used to manage programs.
B. Storage Management mainly manages memory resources
C. File Management can effectively support file operations and solve file sharing, confidentiality and protection problems
D. device management refers to the management of all input and output devices in the computer system except the CPU and memory.
Ii. Short answer
1. What is synchronous and asynchronous? What are the similarities and differences between the two? examples are provided to illustrate the application scenarios. 5 points
1. if data is shared among threads. For example, if the data being written may be read by another thread or the data being read may have been written by another thread, the data is shared and must be accessed synchronously.
When an application calls a method that takes a long time to execute on an object and does not want the program to wait for the return of the method, asynchronous programming should be used, in many cases, adopting asynchronous channels is often more efficient.
2. Five la s commonly used in Android, and briefly describe the characteristics of these commonly used la S. 10 points
2. Question 2: Five la s
1. FrameLayout
This layout can be seen as a heap of the wall. There is a wall foot in the upper left corner of the rectangular square. We put the first thing, and we want to put another one, which is placed on the top of the original place, in this way, it will cover the original things. This layout is relatively simple, and you can only put something simple.
2. LinearLayout
Linear layout, which can be understood as a div from the external frame. First, it is listed one by one on the screen. Each LinearLayout can be divided into vertical layout (android: orientation = "vertical") and horizontal layout (android: orientation = "horizontal "). In vertical layout, each row has only one element, and multiple elements are vertical down in sequence. in horizontal layout, there is only one row, and each element is arranged to the right in sequence. LinearLayout has an important attribute android: layout_weight = "1". In vertical layout, this weight represents the line spacing; in horizontal layout, it represents the column width; the larger the weight value, the larger the value.
Iii. AbsoluteLayout
The absolute layout is like that div specifies the absolute attribute, and uses the X and Y coordinates to specify the element location. android: layout_x = "20px"
Android: layout_y = "12px" is a simple layout method. However, when you switch between the two elements vertically, problems often occur. In addition, computing is troublesome when multiple elements are involved.
Iv. RelativeLayout
The relative layout can be understood as the layout method for positioning an element as a reference object. Main attributes include:
Relative to an element
Android: layout_below = "@ id/aaa". The element is under aaa.
Android: layout_toLeftOf = "@ id [poop] B" the left side of this element is bbb.
Relative to the parent Element
Android: layout_alignParentLeft = "true" align left of the parent Element
Android: layout_alignParentRight = "true" indicates the right alignparentright of the parent element. You can also specify margins. For details, see API
5. TableLayout
The Table layout is similar to the Table in Html. Each TableLayout contains the table row TableRow, which can define each element and set its alignment mode android: gravity = "".
Each layout has its own method. In addition, these five layout elements can be nested with each other to create a beautiful interface.
3. write the if statement for comparing BOOL flag with zero value; write the if statement for comparing float x with zero value; write the if statement for comparing char * p with "zero value"; 5 points
BOOL if (! Var)... and if (var )...
If (var> =-EPS) & (var <= EPS)... and if (var> = EPS | var <=-EPS) of float)
Char *'s if (var = NULL)... and if (var! = NULL )...
4. There are several types of memory allocation areas, and the functions of each memory area are briefly described; 10 points
1. Program counters
Each thread has an independent program counter, which is used to record the bytecode instruction to be executed by the current thread. The memory area of this class is "thread private" memory.
2. Virtual Machine Stack
It is mainly responsible for the memory part of method execution. During each method execution, a stack needle is created to store local variables, operands, and other method-related information. Each method call is complete, all correspond to the process of a stack needle entering and exiting the stack in the VM stack.
3. Local method Stack
Similar to the VM stack, it is only responsible for the LOCAL Native method and will throw stackOverFlowError and OutOfMemoryError.
4. JAVA Heap and GC Heap
The main object storage instance can be configured to set different generation size and garbage collection policies. Many optimizations are also implemented on the stack.
5. Method Area, non-heap, permanent generation
It mainly stores information about classes, constants, and static variables loaded by virtual machines.
6. Direct Memory
The direct memory is not shown in the figure. It is thought that it is not part of the data zone of the VM runtime and is not managed by the VM,
5. The architecture of the Android system is illustrated in diagrams or text. 5 points
Android adopts a hierarchical architecture like its operating system. From the structural diagram, android is divided into four layers: application layer, application framework layer, system Runtime Library layer, and linux core layer.
6. Advantages and principles of Java garbage collection, and two collection mechanisms are considered. 5 points
The program can use System. gc () or Runtime. getRuntime (). gc () to request garbage collection. Working principle: reference counting, marking Replication
Advantages and disadvantages of the garbage collection mechanism: Java's garbage collection mechanism does not concern programmers about the allocation of memory space, which reduces memory overflow, but also sacrifices some performance.
7. Definitions and features of Activity, Intent, ContentProvider, and Servide in Android. 5 points
Activity: Activity. An activity is a Visualized User interface that users can operate. Each activity is implemented as an independent class and inherited from the activity base class.
Intent: Intent. The most important part is the data corresponding to actions.
Content Provider: Content Provider. android applications can save their data to files, SQLite databases, or even any valid device. When you want to share your application data with other applications, the content provider can play a role.
Service: a Service that has a long life cycle and has no user interface.
8. What are the advantages and disadvantages of Java serialization and how to implement serialization. 5 points
8 serialization is a mechanism used to process object streams. Object streams are called object streams that stream object content. You can perform read and write operations on Streaming objects, or transfer streaming objects between networks.
Serialization implementation: implement the Serializable interface for the class to be serialized. There is no implementation method for this interface. implementsSerializable is only used to indicate that the object can be serialized, then, an output stream (such as FileOutputStream) is used to construct an ObjectOutputStream (Object stream) Object. Then, the writeObject (Object obj) of the ObjectOutputStream Object is used) method, you can write the object whose parameter is obj (that is, save its status). To restore the object, use the input stream.
9. The output result of the following program is ___ C ___. Int t (int x, int y, intcp, int dp) {cp = x * X + y * y; dp = x * x-y * y;} main () {int a = 4, B = 3, c = 5, d = 6: t (a, B, c, d); printf ("% d \ n ", c, d );
A.4 5
B .4 6
C.5 6
D.5 5
10 interrupt is an important part of embedded systems, which causes many compilation developers to provide an extension to interrupt Standard C support. The fact is that a new keyword _ interrupt is generated, and the following code uses the _ interrupt keyword to define an interrupt service subroutine (ISR ), please comment on this code to find out the error and correct it. point out the problem:
_ Interruptdouble compute_area (double radius)
{
Double area = PI * radius;
// Printf ("Area = % f", area );
Return area;
}
1. ISR parameters cannot be passed, and void must be used;
2. ISR should be short and efficient. Therefore, it is not recommended to perform floating-point operations in ISR. Instead, the application layer should handle other work by sending messages or position signs by interruption;
3. There should be no re-entry and performance problems in ISR, so pintf () function is not good.
11. How can I use two stacks to implement a queue function? Algorithms and ideas are required. 10 points
# Include <iostream>
# Include <stack>
Class TMyQueue
{
Private:
Stack <char> s1, s2;
Public:
Void push (char c)
{
While (! S2.empty ())
{
Char x = s2.top ();
S2.pop ();
S1.push (x );
}
S1.push (c );
}
Char pop ()
{
Char c;
While (! S1.empty ())
{
Char x = s1.top ();
S1.pop ();
S2.push (x );
}
C = s2.top ();
S2.pop ();
Return c;
}
Bool empty () const
{
Return s1.empty () & s2.empty ();
}
};
Int main ()
{
TMyQueue q;
Int I;
Char buf1 [4] = "one ";
Char buf2 [4] = "two ";
Char buf3 [6] = "three ";
For (I = 0; I <3; I ++)
Q. push (buf1 [I]);
For (I = 0; I <3; I ++)
Q. push (buf2 [I]);
For (I = 0; I <3; I ++)
Cout <q. pop ();
Cout <endl;
For (I = 0; I <5; I ++)
Q. push (buf3 [I]);
While (! Q. empty ())
{
Cout <q. pop ();
}
Cout <endl;
Return 0;
}