Kristofer Younger 0bb9ffb465 Update 'README.md' | 6 년 전 | |
---|---|---|
README.md | 6 년 전 |
some questions for you to answer and ponder. the sooner, the better...
Describe the features of Java for controlling the repeated execution of a block of code. Show how general uses of for, while and do could all be emulated using only loops that start of while (true).
Describe some circumstances where it is useful for functions to return errors as exception, and some where it is not. Give an example of an algorithm which is simplified by the use of exceptions.
Java comes with a class BigInteger that represents potentially huge numbers. Suppose it did not, or for some reason you were prohibited from using it but still needed to work with large positive integers. To fit your needs you will define a new class called Big that stores integers as arrays of byte values, where each byte holds a single decimal digit from the number being used, with the least significant digit held at position 0 in the array. Write a definition of such a class including in it methods to create a big integer from an int (provided that int is positive), to add two Big values together and to convert from a big to a String ready for printing. You need not implement any other methods unless they are needed by the ones mentioned here.
A list in Java can be represented as a sequence of links. Each link is an object containing one value in the list and a reference to the rest of the list following the link. A null reference indicates the end of the list. Write a Java class that can represent such lists, where the items stored in lists are of type Object. Provide your implementation with two static public methods that append lists. The first of these should be called append and should take two arguments, its result should be the concatenation of the two lists and neither input should be disturbed. The second should be called conc and should have the same interface, but it should work by altering the final reference in the first list to point it towards the second, and it should thus not need to use new at all.
Some Tiny Questions 1 List the eight Java primitive data types. 2 What is a class? 3 Name the java access modifies for instance variable, classes and methods. 4 What can an abstract class do that an interface cannot? 5 What result will be printed if the following fragment of Java code is executed? Why?
System.out.println(‘h’+’e’+”llo worl”+’d’)
6 What result will be printed if the following fragment of Java code is executed? Why? ```
double d = 6.6;
try
{ d=1.0/0.0; }
finally
{
System.out.println("d = " + d);
}
```