Multiple choice questions:
1. Which of the following is correct regarding application request, category, and packages? (And the)
A package, import, class
class, import, package
C. Import, package, class
D. Package, class, import
2. Which of the following is correct? (Dr)
A. Temperature series [] = new string {“a” “b” “c” };
B. String temperature [] = {“a” “b” “c”}
c. String temp = {“a”, “b”, “c”}
D. Temperature series [] ={“a”,”b”,”c”}
3. About the java.lang.string class, the following description is correct (a)
A. The String class is the final class and cannot be inherited;
B. The String class is the last class that can be inherited;
The String class is not inherited by the final class;
d- The String class is not the final class that can be inherited;
String class is final. in java
4. Regarding the instance method and class method, the following description is correct: (d)
A. The instance method can only get instance variables.
B. Class methods can access class variables, or an instance variable can be accessed
c. A class method can only be called by the class name
D. The instance method can only be called by an object
The instance method can access class variables
Class b method can only get class variables
Class C methods can be called through objects
5. An interface is one of the implementation mechanisms of the Java object. The following statement is correct: (b)
A. Java supports multiple inheritance, a single class can access multiple interfaces;
B. Java only supports single inheritance, a single class can access multiple interfaces;
C. Java only supports single inheritance, only one class can implement one interface;
Dr.. Java supports multiple inheritance, but a class can only implement one interface.
Java supports single inheritance. Only one class can inherit from one class, but a single class can access multiple interfaces.
6. The following statement about interface is correct: (d)
A An interface can have a private style
B. An interface can have a final method
C interface can be implemented with functions
Dr.. An interface can inherit from other interfaces
A There is no private method in the interface
B. A method in the interface cannot have a method in the interface.
c. A method in an interface cannot be executed
7. Knowing that class A is packaged in Packagea, class B is packaged in PackageB, class B is declared publicly, and the member variable x is declared as a protected controller method. Class C also falls into Packagea and inherits class B. Then the following is true (c)
An instance of class A cannot access an instance of class B
Class A instances can access an X instance of class B
Instance of C. Class C can access instance X of class B
D. Instances of class C cannot access an instance of class B
Many cakes can reach parent class B security personnel
8. Correct output for the following program: (a)
package test;
public class FatherClass {
public FatherClass() {
System.out.println(“FatherClass Create”);
}
}
package test;
import test.FatherClass;
public class ChildClass extends FatherClass {
public ChildClass() {
System.out.println(“ChildClass Create”);
}
public static void main(String[] args) {
FatherClass fc = new FatherClass();
ChildClass cc = new ChildClass();
}
}
a.
Create a parent class
Create a parent class
Create ChildClass
B.
Create a parent class
Create ChildClass
Create a parent class
c.
Create ChildClass
Create ChildClass
Create a parent class
Dr..
Create ChildClass
Create a parent class
Create a parent class
super() is at the beginning of the beginning of the sub constructor;
9. Give the following code that can be used as a constructor that can be used as a class (B)
public class Test {
?
}
a. public void test() {?}
B. public test() {?}
c. public static test() {?}
Dr.. static public void test() {?}
Constructor method: no return type with the same class name
10. Name:
public class test (
public static void main (String args[]) {
int i = 0xFFFFFFF1;
int j = ~i;
}
)
When the program runs up to the fifth line, what is the value of j? (Dr)
a. -15
b 0
C 1
D 14
E. An error in the third line causes compilation to fail
int i = 0xffffffff1; Equivalent to int i = -15 and then takes the absolute value of the absolute value of I
11. About Sleep() and Wait(), the following is the wrong topic (D)
A. Sleep is a method of the Thread (Thread) class. wait object class;
B. Sleep does not release the object lock, wait to release the object lock;
C. Sleep Pause threads, but the monitoring state is still preserved, and it will be automatically restored after completion;
D. wait After entering the pending lock pool, only a notify method is issued for this object to bring the object’s lock to the running state.
Sleep is a method of a Thread (Thread) class that causes this thread to stop executing for the specified time and let other threads execute, but the monitored state is still preserved and will be automatically restored after that. Calling sleep will not release the object lock.
Wait – This is a method of the Object class. Acquiring a wait method on this object causes this thread to release the lock on the object and enter the wait lock pool while waiting on this object. Only after the notify (or notify) method of this object is released is the object. The castle enters into operation.
12. The following allows a thread to stop executing (multiple choice) (ABDEF)
sleep () ;
to stop () ;
c. notify();
synchronous ();
e yield ();
F. wait();
notifyAll();
Sleep: This thread causes execution to be suspended for the specified time
Stop: This method will terminate all non-responsive methods, including the run method.
synchronous(): Lock the object
Yield: At this time, it may seem that the processor’s service quality is not enough, so I go out in advance, which is the payoff.
Wait: The currently rendered branch must sleep for a while, and after waking up, continue rendering
13. Which of the following can change the design of a container? (And the)
a. setLayout(aLayoutManager);
B. addLayout(aLayoutManager);
C layout(aLayoutManager);
D. setLayoutManager(aLayoutManager);
Set settings Java Mayout Manager setLayout()
14. Which of the following is the correct way to pass lowercase parameters? (B)
a.
B.
c.
D. <الصغير اختبار 33>
15. Cannot be used to change interface (ACD)
private
Bob Public
protected
D.static
The modified interface can be public or virtual
16. The following statement is wrong (ACD)
c. In a class method, you can use this to call that class’s class method
B. When calling a class method in a class method, you can call it directly
c. In a class method, a class method can only be called a class method in this class
E. Do not call an instance method in a class method
a In the class method, you cannot use this keyword
c. You can call the class method in other classes in the class method
E. In the class method, the instance method can be called through the object instances
17. Select the “correct code segment” ( ) in the following four paragraphs code (a, b, c, d)
A.abstract class Name {
private String name;
public abstract boolean isStupidName(String name) {}
}
B.public class Something {
void doSomething () {
private String s = “”;
int l = s.length();
}
}
C.public class Something {
public static void main(String[] args) {
Other o = new Other();
new Something().addOne(o);
}
public void addOne(final Other o) {
o.i++;
}
}
class Other {
public int i;
}
D.public class Something {
public int addOne(final int x) {
return ++x;
}
}
Ah… abstract methods can’t be decent
B. The method is specified using local variables.
E. The final adjustment is permanent, the value of the constant cannot be changed
18. Determine the results of the following code: (c).
public class Test{
public void method()
{
for(int i = 0; i < 3; i++){
System.out.print(i);
}
System.out.print(i);
}
}
A.0122
B.0123
C compilation error
D. No withdrawal
The scope of the first variable is the entire cycle
19. Please see the following code
class Person {
private int a;
public int change(int m){return m;}
}
public class Teacher extends Person{
public int b;
public static void main(String arg[]){
Person p = new Person();
Teacher t = new Teacher();
int i;
}
}
Which of the following is correct? (Germany)
a, i = m;
b, i = b;
c, i = Pa;
d, i = p-change (30);
e, i = TB;
a. different role areas
Non-static member variables cannot be used directly in static methods
c. Other types of private members cannot be accessed outside of the class
D, E. In the class method, you can use the copy members in the taxonomy class
Answer questions:
1. Briefly describe the SOA architecture.
SOA architecture is the architecture of a service.
A service-oriented architecture is a component model that connects various functional modules (called services) of ZHI applications through these services, which define interfaces and good contracts.
The interface is defined in a neutral way. It must be independent of the hardware platform, operating system, and programming language of the service. This allows the service embedded in many of these systems to interact in a unified and global manner.
SOA has the following five characteristics:
1. Можно использовать повторное использование
2. Свободная связь
3. Четко определенное интерфейс
4. Без дизайна обслуживания без сохранения состояния хранения
5. На основании открытых стандартов
2. TherPC service and RESTFUL service difference (recommended to deepen your understanding of RPC and RESTFUL)
1. In terms of fundamental differences, RPC is based on TCP and RESTFUFL is based on HTTP.
2. In terms of throughput, because the amount of data encapsulated by HTTP is larger, the data throughput is higher, so the RPC throughput is faster than RETFUL.
3. Because the HTTP protocol is usually supported by each framework. In the case of TOC, since the source structure and data state are not known, the gateway may receive RESTFUFL at the gateway. Since each module within a microservice is mapped by each protocol decision, it is known that different data methods can be used to pass data between each module. Therefore, you can use RPC between the gateway and the external data transfer.
4. Resource-oriented REST API design. To get, pass, and modify the same resource, you can use Get and Post to mark the same URL, and RPC usually maps the verb directly to the URL.
3. What is a deadlock and how to solve it
Dead Lock: Two processes A and B are holding resources and waiting for B resources, B holding resources B waiting for resources. Both processes are waiting for a different resource than the one that was issued which causes deadlocks.
Четыре необходимых условия для формирования мертвых замков:
(1) Взаимное условие: ресурс может использоваться только одним процессом за раз.
(2) Условия и условия обслуживания: когда процесс заблокирован из -за запроса ресурсов, он сохраняет замечательные ресурсы.
(3) Не лишайте условий: ресурсы, которые были получены процессом, не могут быть насильственно лишены до последнего использования.
(4) Условия круговых ожиданий: между несколькими процессами образуется соотношение ресурсов для ожидания цикла между головой и хвостом.
> решать:
1.Прежде всего, выполняемый подход заключается в том, чтобы выпустить все замки, вернуть и дождаться случайного времени, чтобы повторно повторно.
Это похоже на простой тайм -аут.
2.Отступление и подождите, но если в одной и той же партии замков будет много конкуренции за потоками, они все равно будут повторять замок (примечание: причина аналогична сверхурочной работы, и конкуренция не может быть принципиально смягчена).
3.Лучшее решение - установить приоритет для этих потоков, чтобы можно было возвращать один (или несколько) потоков. Остальные потоки продолжают сохранять свои потребности в необходимых им замках.
Если приоритет, указанный в этих потоках, зафиксирован, одна и та же партия потоков всегда будет иметь более высокий приоритет. Чтобы избежать этой проблемы, случайный приоритет может быть установлен, когда возникает тупик.
Programming questions:
1. Topic: Classic Questions: There are two pairs of rabbits. From the third month after birth, a pair of rabbits are given every month, and the rabbit raises a pair of rabbits every month after the third month. Any number. Rabbits per month (Fibonacci number)?
Program analysis: bunnies bases take 1,1,2,3,5,8,13,21…
public static void main(String[] args){
int n = 10;
System.out.println(""+n+«Общее количество кроликов составляет»+fun(n));
}
private static int fun(int n){
if(n==1 || n==2)
return 1;
else
return fun(n-1)+fun(n-2);
}
2. Title: How many prime numbers are between 101-200 and take out all the prime numbers.
Program Analysis: Prime Number Evaluation Method: Delete 2 to SQRT with a single number. If it can be removed, it indicates that this number is not the main number, otherwise it is the main number.
public static void main(String[] args){
int m = 1;
int n = 1000;
int count = 0;
for(int i=m;i<n;i++){
if(isPrime(i)){
count++;
System.out.print(i+" ");
if(count%10==0){
System.out.println();
}
}
}
System.out.println();
System.out.println("существовать"+m+"с"+n+"Все вместе"+count+"Точки");
}
private static boolean isPrime(int n){
boolean flag = true;
if(n==1)
flag = false;
else{
for(int i=2;i<=Math.sqrt(n);i++){
if((n%i)==0 || n==1){
flag = false;
break;
}
else
flag = true;
}
}
return flag;
}