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