Tuesday, 31 October 2017

java theory problems



Question 01
  Identify and fix the errors in the following code:
 public class Test {
 public void main(string[] args) {
 double i = 50.0;
 double k = i + 50.0;
 double j = k + 1;
 System.out.println("j is " + j + " and
 k is " + k);
 }
}
Ans  Errors
01 String letter must be capital.
02 In main function there is an error no write static class
02  The output statement must be written as when write in two lines System.out.println("j is " + j + " and"
         + " k is " + k);
Question 02
Are there any performance differences between the following two import statements?
import java.util.Scanner;
import java.util.*;
Ans:
 Scanner is the class of java.util package.import java.util.Scanner is used for specific class.
But import java.util.*; is used to access all the classes of java.util package.

No comments:

Post a Comment