Log in

View Full Version : [HELP] Mohon Penjelasannya gan


Braincode
11th November 2011, 01:14 PM
Gan, boleh minta bantuannya ga? ane dikasih tugas sama dosen ane, tp ane ga ngerti kerjain nya, ane mohon penjelasan dr agan" yang ngerti Java biar ane bisa kerjain nih tugas :p



Thx before :handshake:



Begini gan soalnya:




Quote:





1. (using the Math.sqrt method) write a program that printa the following table using the sqrt method in the Math class.



Number squareRoot



0 0.0000



2 1.4142



�..



18 4.2426



20 4.4721







2. Suppose that s1 and s2 are two strings. Which of the following statements or expressions are incorrect?







String s = new String(�new string �);



String s3 = s1 + s2;



String s3 = s1 � s2;



s1 == s2;



s1 >= s2;



s1.compareTo(s2);



int i = sl.length();



char c = sl(0);



char c = sl.charAt(sl.length());







3. Describe primitive-type wrapper classes. Why do you need these wrapper classes?



4. What is wrong in the following code?





public class Test {



public static void main(String[] args) {



Number x = new integer(3);



System.out.println(x.intValue());



System.out.println((integer)x.compareTo(new Integer(4)));



}



}





5. What is output of the following code?







public class Test {



public static void main(String[] args) {







System.out.println(integer.parseInt(�10�));



System.out.println((integer.parseInt(�10�,10));



System.out.println((integer.parseInt(�10�,16));



}



}








</div>