Home > Back-end >  Have your homework today, everyone see, to do homework together
Have your homework today, everyone see, to do homework together

Time:12-02

Exercise 1:
1. Why is the input of characters, the output is the code?
2. Write the detailed improving methods,
Import the Java. IO. *;
The class IOTest
{public statics void main (String args [])
{the try {byte bArray []=new byte [128].
System. The out. Println (" Enter something: ");
System. In the read (bArray);
System. The out. Print (" You rose: ");
System. The out. Println (bArray);
} the catch (IOException ioe)
{System. Out. Println (ioe. ToString ()); }
}
}





Exercise 2,
That the exception handling mechanism in Java? If the try {} have a return statement, then follow the finally after this try {} in the code will be executed? Why is that?



Practice three, encapsulation, inheritance, polymorphism of the three cornerstones of object-oriented, please give explanation to these three respectively,




What is the difference between practice four, overloading and rewrite?




Exercise 5. What is the relation and distinction between Throw/throws?




CodePudding user response:

Practice 1.
1. Because the output is an array of addresses rather than characters
2. The method of character into the string

Practice 2.
Will perform, execute before the return, and finally the first code execution, the execution of the code in the try, because there is also a return of the finally, finally return to the return of the finally,

Practice 3.
1, surrounded by encapsulation is the process and data access to data only through defined interfaces,
2, inheritance to derive a new class from an existing class, the new class can absorb existing classes of data properties and behaviors, and can extend the new ability,
3, is due to inheritance and polymorphism rewriting mechanism, the same type of object, perform the same method, the result may be different,

Exercise 4.
Rewrite: a subclass bai zhi du cover father class method, the method name and parameters are the same;
Overloading: two or more than two in the same class of methods, with the same method name, but are not the same parameters, method body is also different,

Practice 5.
Throws is a method used to declare bai might throw of the zhi du all abnormal information
Throw is behind the dao of a specific exception type,
Usually at a method (class) statement by throws the declarative approach (class) may be thrown exception information, while inside the method (class) by throw declare a specific exception information,
Throws usually don't have to show an exception, but by the system automatically will throw any exceptions that capture information to the superior method;
Throw requires users to capture relevant abnormalities, and then on its associated packaging, finally in the thrown exception information to the carrier,


  • Related