JAVA Detail Finishing __java

Source: Internet
Author: User

1. What is the result of executing the following code? int x,a=2,b=3,c=4; x=++a+b+++c++;


This equates to x= (++a) +b+c;   b++;c++ | Post + + After the end of the operation, Pre + + before the operation to perform | So the result is x=10 a=3 b=4 c=5


2. Which of the following expressions is correct?

A String s= "Hello"; int i=3; S+=i;

B String s= "Hello"; int i=3; if (i==s) {s+=i};

C String s= "Hello"; int i=3; S=i+s;

D String s= "Hello"; int i=3; s=i+;

E. String S=null; Inti= (s!=null) && (s.length>0)? S.length (): 0;

AE a:s+=i; Convert S=i+s to type before performing the + = operation; So the A-expression is correct C-error is more than string, and so are other different types of operations


3 string[] s=newstring[10];

S.length () = 10; Default value of s[0]...s[9] is null;



4 Interface Name Xxx=new interface an implementation class (). This facilitates
1. Easy to standardize the design of the program
2. Work with the team to develop
3. Easy to convert to components
4. Convenient code reuse, no need to know the technical details.





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.