1(java)下面的哪一项将不会产生编译错误或警告:
A、float f=1.3;
B、char c="a";
C、byte b=129;
D、boolean b=null;2、 (java)请描述java中几种访问控制符的区别
3、 (java编程)请分别使用递归和非递归的方式完成函数f(n)=n! + 1 + 2 + … + n,并打印f(10)的值,请写出完整的类。4. Java中的异常处理方式有哪些?5 阅读下面的java代码,执行后的输出结果是
public class A {
public void fun(String strB,B b){
strB = " This is String strB ";
b.val = " This is b.val ";
}
public static void main(String [] args) {
A a = new A();
String strA = " This is String strA ";
B b = new B();
a.fun(strA,b);
System.out.println(strA);
System.out.println(b.val);
}
};
class B{
String val;
public B(){
this.val = " This is class B ";
}
}
A. This is String strA
This is class B
B. This is String strB
This is b.val
C. This is String strA
This is b.val
D. This is String strB
This is class B
A、float f=1.3;
B、char c="a";
C、byte b=129;
D、boolean b=null;2、 (java)请描述java中几种访问控制符的区别
3、 (java编程)请分别使用递归和非递归的方式完成函数f(n)=n! + 1 + 2 + … + n,并打印f(10)的值,请写出完整的类。4. Java中的异常处理方式有哪些?5 阅读下面的java代码,执行后的输出结果是
public class A {
public void fun(String strB,B b){
strB = " This is String strB ";
b.val = " This is b.val ";
}
public static void main(String [] args) {
A a = new A();
String strA = " This is String strA ";
B b = new B();
a.fun(strA,b);
System.out.println(strA);
System.out.println(b.val);
}
};
class B{
String val;
public B(){
this.val = " This is class B ";
}
}
A. This is String strA
This is class B
B. This is String strB
This is b.val
C. This is String strA
This is b.val
D. This is String strB
This is class B
a)1.3默认为double型,不能直接赋给 float,需加 f ,或强制向下转换
b)"a"为字符串,不能给字符型
c)byte 最大为127
d)基本类型boolean不能直接赋为null
2)百度
3)非递归
for(int i; i<=n; i++){
sum=sum+i;
}
递归
f(n){
if(n==1){
return 1;
} else {
return n + f(n-1);
}
4)捕获、抛出
5)C