Thoughts on Java Final Exam

Source: Internet
Author: User

The fall semester Java has already closed the lesson, when sees the academic affairs platform posted the notice to say that the examination form is the single topic, the heart is happy mixed.

It is gratifying that this form of examination is still relatively popular, after all, in addition to judgment, the best thing to do is a single-choice question.

However, the mid-term selection of 50% of the hit rate is still vivid, the heart worries. Then it turned out that my worries were not unreasonable, abused again, and abused without complaining.

After the exam, the impression of a few of the topics ran on eclipse, the result is also unbearable ....

Then I decided to write them down in order to be ashamed before the snow in the near future.

#1. Yes, you did not read wrong, this is the problem, I was relying on excellent reverse thinking contended answer is 11, the result. Positive Solution 12.

 Public class Testexam {    publicstaticvoid  main (string[] args) {                long i = math.round (11.5);        System.  out . println (i);            }}

#2. Which of the following classes does not override the ToString () method and the Hashcode () method. String Double Character StringBuffer

I chose the double class, in fact, the double class overrides the above method, and the StringBuffer class is not rewritten.

1  Public classTestexam {2      Public Static voidMain (string[] args) {3         4Double D1 = 123.45;5Double D2 = 123.45;6         BooleanFlag =D1.equals (D2);7 System.out.println (flag);8         9     }Ten  One}

#3 What are the results of the following program output? (The point of knowledge is really vague, unclear)

1  Public classTestexam {2      Public Static voidMain (string[] args) {3         4String S1 =NewString ("a");5S1 = S1 + "B";6System.out.println (S1 = = "AB");//false7String s2 = "a" + "B";8SYSTEM.OUT.PRINTLN (s2 = = "AB");//true9     }Ten  One}

#4 the range of values for char types .... Just remember that char is two bytes, 16 bits, not hesitate to choose-65536-65535, it turns out that any decision not to think is absurd. Positive Solution 0-65535

#5 the results of the following programs:

 Public class extends thread{    publicstaticvoid  main (string[] args) {                    new  Thread ();        T.start ();        System.out.println ("one");        T.start ();        System.out.println ("both");            }          Public void run () {        System.out.println ("Thread");}    }

The correct answer is that when the program runs, it throws an exception, not the compilation error (Complie fail) I chose.

Thoughts on Java Final Exam

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.