第五题
java的四个访问修饰符:
访问权限 类 包 子类 其他包
public ∨ ∨ ∨ ∨
protect ∨ ∨ ∨ ×
default ∨ ∨ × ×
private ∨ × × ×
第六题
A 在Java中类是单继承的,一个类只能继承一个父类
C 子类不可以使用父类中私有的方法
D子类中的方法数量与父类中方法数量无直接关系
操作题
1
import java.util.Scanner;
public class A {
public static void main(String[] args) {
int abcCount=0;
int numCount=0;
int spaceCount=0;
int otherCount=0;
System.out.println("请输入一个字符串");
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
for (int i = 0; i < str.length(); i++) {
char c=str.charAt(i);
if (c>='0'&&c<='9'){
numCount++;
}else if (c>'a'&&c<'z'){
abcCount++;
}else if (c==' '){
spaceCount++;
}else {
otherCount++;
}
}
System.out.println("字母个数为"+abcCount);
System.out.println("数字个数为"+numCount);
System.out.println("空格数量为"+spaceCount);
System.out.println("其它字符数量为为"+otherCount);
}
}
杨辉三角