Home > Back-end >  Java interview questions for bosses to solve these two problems
Java interview questions for bosses to solve these two problems

Time:09-16

Java interview questions
Interview today, due to their bad foundation, a face is veiled, strives for the bosses to solve these two problems,

1, the name of a variable, how different values, how to do?
2, a function has no return value, function in the body to do some calculation, function in vitro how to calculate the values?

CodePudding user response:

2. Use: Supplier, sample
 
Supplier F=() - & gt; UserDao. The.findall ();


1. Java is a strongly typed language on the surface after is not open

CodePudding user response:

1, the name of a variable, how different values, how to do?
Re:

If it is a collection or polymorphism, also can meet the description, because it does not say at compile time, or the type of runtime

CodePudding user response:

1 the Object variable of type
The Object o=5;//save the Integer
O="five";//save the String

2 using passing parameter
Void fun (StringBuilder buf) {
Buf. Append (" return value ");
}
The
The StringBuilder buf=new StringBuilder ();
Fun (buf);
System. The out. Println (buf);

CodePudding user response:

1, there is no limit to the variable scope, different scope of variables with the same name can be different types, so different values, of course, no problem, such as static variable and a local variable
2, the function has no return value, but can be calculated in the body of the function of value passed to the accessible storage object

CodePudding user response:

1. Set can meet the same variable to store different values
2. No return value, but to do the calculation in the method, the calculation result can be as a global variable deposit, and the in vitro method can be used the function return value

CodePudding user response:

refer to the building of a hair program apes reply:

Java interview questionsInterview today, due to their bad foundation, a face is veiled, strives for the bosses to solve these two problems,

1, the name of a variable, how different values, how to do?
2, a function has no return value, function in the body to do some calculation, function in vitro how to calculate the values?


1. Said is variable, with the same two variables, that is, one can be a global variable and a local variable,

2. There is no return value function can be use global variables, so the body of the function also can obtain the value of the variable

These are the basis,

CodePudding user response:

First question should be able to do many explanations, as long as you can justify estimates should be no problem,

The second question asked was handed reference object type, as long as replied object types reference basic, there is no problem,

CodePudding user response:

1. The variable can be two different objects with the same amount of
2, and function into the parameter set as a reference type, the result come out through it

CodePudding user response:

The
reference 3 floor qybao response:
1
Object types of variablesThe Object o=5;//save the Integer
O="five";//save the String

2 using passing parameter
Void fun (StringBuilder buf) {
Buf. Append (" return value ");
}
The
The StringBuilder buf=new StringBuilder ();
Fun (buf);
System. The out. Println (buf);

The elder brother, two questions are right, one question, the somebody else say variables to save different values of the same name, not a variable storage of different types of values,
The second topic ditto,
Write a topic, not the same,
Such as CLASSA. FIELD1=AAA;
CLASSB. FIELD1=100;
The variables with the same name of the different values, or different types,

CodePudding user response:

Feel this exam, don't go, I generally don't such a problem, was asked to also don't know,
Don't like doing technology

CodePudding user response:

Problem 1, it should be in examining the concept of scope, as long as to understand the scope, nature can answer, different scope of variables, with the same type and value can be different,
Question 2, should be in examining the reference function parameters, to be returned by the data encapsulation into object as a parameter passed into the function, when the function returns, the access to the object parameters can be calculated as a result,

CodePudding user response:

I also come under review, (2) the reference type parameters, changes in the method, the examination site is your values, the modified method of value scope is: but you address values, it won't be the same, is through the address values to find your position actually stored in the memory of the parameters of the value of the modified operation, I have changed the nature of your place you can be the same? Similar to the c language pointer, this is my understanding of the second q====freshman year to play

CodePudding user response:

Do computing function in the body, function in vitro in calculation value, this method can be a lot of, in the function body persistent data directly, who want to take who take,
  • Related