Understanding Java Data-Types and Functions
1.Convert to decimal numbers:
- 000010012
- 000001112
- 000010102
top
2. Convert to binary numbers (assume byte (8 bits) datatype)
top
3.Calculate binary result and convert your result to decimal number (assume byte (8 bits) datatype):
- 000010012+000010012
- 000001112+000010012
- 000010102+111110012
top
4.Find the mistake in the following class definition:
public class Test_fun2 {
public static void f1 (int x, int y){
System.out.println("f1, x="+x+";
y="+y);
};
public static int f1 (int x, int z){
System.out.println("f2, x="+x+";
z="+z);
return x;
};
public static void main(String args[]) {
int x,y,z;
x=0;y=0;z=0;
System.out.println("in
Class Test_fun");
System.out.println("z="+z);
f1(x,y);
int i=f1(x,z);
};
};
top
5.Predict the output of the following program:
public class Test_fun3 {
public static int z;
public static int f1 (int x, int y){
System.out.println("f1, x="+x+";
z="+z);
return x;
};
public static int f1 (double x, int z){
System.out.println("f2, x="+x+";
z="+z);
return z;
};
public static void main(String args[]) {
System.out.println("in
Class Test_fun");
z=0;
int x=f1(1,1);
System.out.println("after (a),
x="+x+"; z="+z);
x=f1(1.0,5);
System.out.println("after (b),
x="+x+"; z="+z);
};
};
top
|