本题统计score[]={37,89,63,60,59,78,91)中成绩不及格的人数。public class javal{public static void main(String[]args){int score[]={37,89,63,60,59,78,91),int sum=0:int i=0;while(i<;score.length){if(score[i]>;=60){;;};i++;}System.OUt.println("below 60 sum:"+sum);}}
本题统计score[]={37,89,63,60,59,78,91)中成绩不及格的人数。
public class javal{
public static void main(String[]args){
int score[]={37,89,63,60,59,78,91),
int sum=0:
int i=0;
while(i<;score.length){
if(score[i]>;=60){
;
;
}
;
i++;
}
System.OUt.println("below 60 sum:"+sum);
}
}
相关考题:
下列程序片段中,能通过编译的是A.public abstract class Animal{ public void speak();}B.public abstract class Animal{ public void speak(){}}C.public class Animal{ public abstract void speak();}D.public abstract class Animal{ public abstract void speak(){}}
本题中定义了一个带有参数的构造方法javal,并定义了一个该类的对象temp。构造方法javal有两个参数:字符串name和整型age。定义对象temp时将字符串“Tom"和整数17传递给构造方法,构造方法将这两个参数打印输出。 public class javal{ String name; int age; public static void main(String[]args){ String name="Tom"; int age=17; javal temp = ; } public javal(String name, ){ ; this.age= age; System.out.println(name+"is"+age+" years old."); } }
本题中定义了长度为20的-维整型数组a,并将数组元素的下标值赋给数组元素,最后打印输出数组中下标为奇数的元素。 public class javal{ public static void main(String[]args){ int a[]= Int i: for a[i]=i for i++) =1: i=0;i20;i++){ System.out.print(”a[”+i+”]=”+a[i]+”,“); }
本题统计字符串str中字母a出现的次数,其中str为“(7amp;asdfasdf873eat687al(4a”,字母a存储在字符变量c中,最后打印输出结果。public class javal{public static void main(String[]args){String str=(*amp;7asdf adf873eat687al(4a;char c;int sum=0;int i=0:do{c= ;if( )sum++:i++:}while( );System.out.println(sum=+sum);}}
Given:Which method will complete this class?() A.public int compareTo(Object o){/*more code here*/}B.public int compareTo(Score other){/*more code here*/}C.public int compare(Score s1,Score s2){/*more code here*/}D.public int compare(Object o1,Object o2){/*more code here*/}
下列程序片段中,能通过编译的是( )。A.public abstract class Animal{public void speak( );}B.public abstract class Animal{public void speak( ){};}C.public class Animal{pubilc abstract void speak( );}D.public abstract class Animal{pubile abstract void speak( ){};}
下列虚基类的声明中,正确的是( )。A.class virtualB:public AB.virtual classB:public AC.class B:public A virtualD.class B:virtual public A
本题的功能是获得字符串“China”的长度和最后一个字符,并将这些信息打印出来。 public class javal( public static void main(String[]args){ ; str="China"; int n=0: ; char C; ; System.out.println("字符串中共有"+n+"个字 符,最后一个字符是:"+c); } }
本题提示输入年份,然后判断该年份是否为闰年。 importjava.io.*; public class javal{ public static void main(String[]args){ InputStreamReader ir; BufferedReader in; ir=new InputStreamReader(System.in); in=new BufferedReader(ir); int year=1900; System.out.print("请输入年份:"); try{ String s=in.readLine; ; } (Exception e){ } if( ) System.OUt.println(year+"是闰年"); else System.out.println(year+"不是闰年"); } }
本题利用递归方法求前n个自然数的和(n=lO)。 public class javal{ public static void main(String[]args){ int sum=add(10): System.out.println("1+2+…+9+10="+ sum); } public static int add( ){ if(n= =l){ ; } else ; } }
本题定义了一个求两个数的最大值的方法max,并调用该方法计算67和23的最大值。 public class javal{ public static void main(String[]args){ javal temp=new javal; int res=max(67,23); System.out.println("res="+res); } static int maX( ){ int maxNum; if(ab) ; else maxNum=b; ; } }
本题的功能是求1~100的自然数的累加,并打印输出计算结果。public class javal{public static void main(String[]args){int sum=0;int i=1;for(;;){if( ){sum=sum+i:}else’;}System.OUt.println("sums="+sum);}}
本题读取用户输入的字符流,直到用户输入字符串quit后结束。importjava.io.*;public class javal{public static void main(String[]args){;BufferedReader in;ir=new InputStreamReader(System.in);in=new BufferedReader(ir);System.OUt.println("please input:");while( ){try{String s=in.readLine();System.out.println("echo:"+s);if(S.equals("quit"));)catch(Exception e){}}}}
本题将数组中arr[]={5,6,3,7,9,1}的各个元素按下标的逆序输出。public class javal{public static void main(String[]args){int arr[]={5,6,3,7,9,1};;n= ;while(n>;=O){System.OUt.print(arr[n]+"");;}}}
本题定义了一个方法add(),用于求两个整形数的和。方法中有两个整形参数a和b,方法体中计算a和b的和sum,并将结果返回。程序中调用add()方法求整数24和34的和,并将结果打印输出。public class javal{public static void main(String[]args){int a=24,b=34;System.out.println(add(a,b));}public static int add( ){;sum—a+b;;}}
本题将一个整形变量opl的二进制的低3位全部变成1。public class javal{public static void main(String[]args){pl=21;int op2=7:res;System.out.println(res);}}
本题的功能是计算l~10之间除了5以外的各个自然数的和。public class javal{public static void main(String[]args){int i=1int sum=0;while(i<;=10){if(i= =5){;;};i++;}System.out.println("sum="+sum);}}
本题中,在下画线上填写代码,指定变量b为字节型,变量f为单精度实型,变量l为64位整型。public class javal{public static void main(String[-]args){b=49;f=8.9f;l=0xfedl;System.out.println(b=+b);System.out.println(f=+f):System.OUt.println(l=+1);}}
本题的功能是统计成绩不及格的人数,分数有89,90, 56,90,89,45。23,45,60,59,61。public class javal{public static void main(String[]args)(int 3score={56。90。89,23,45,61,60,59};int hum=0;;int i=0:while( ){if( )sum++:i++;}System.out.println(”<;60:”+sum);}}
下列程序片段中,能通过编译的是( )。 A.public abstract class Animal{ public void speak;}S 下列程序片段中,能通过编译的是( )。A.public abstract class Animal{ public void speak;}B.public abstract class Animal{ public void speak{);}C.public class Animal{ pubilc abstract void speak;}D.public abstract class Animal{ pubile abstract void speak{};}
Which three demonstrate an “is a” relationship?() A、 public class X { } public class Y extends X { }B、 public interface Shape { } public interface Rectangle extends Shape{ }C、 public interface Color { } public class Shape { private Color color; }D、 public interface Species { } public class Animal { private Species species; }E、 public class Person { } public class Employee { public Employee(Person person) { }F、 interface Component { } class Container implements Component { private Component[] children; }
interface Data { public void load(); } abstract class Info { public abstract void load(); } Which class correctly uses the Data interface and Info class?() A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }
Which two allow the class Thing to be instantiated using new Thing()?A、 public class Thing { }B、 public class Thing { public Thing() {} }C、 public class Thing { public Thing(void) {} }D、 public class Thing { public Thing(String s) {} }E、 public class Thing { public void Thing() {} public Thing(String s) {} }
在C#程序中,如果类B要继承类A,类B正确的定义为()。A、public class B inherit AB、public class B :: AC、public class B : AD、public class B from A
Which the two demonstrate an “is a” relationship?()A、 public interface Person {} Public class Employee extends Person {}B、 public interface Shape {} public interface Rectangle extends Shape {}C、 public interface Color {} public class Shape { private Color color; }D、 public class Species {} public class Animal { private Species species; }E、 interface Component {} Class Container implements Component {private Component [] children;
Which two demonstrate an “is a” relationship?() A、 public interface Person { } public class Employee extends Person { }B、 public interface Shape { } public class Employee extends Shape { }C、 public interface Color { } public class Employee extends Color { }D、 public class Species { } public class Animal (private Species species;)E、 interface Component { } Class Container implements Component ( Private Component[ ]children; )
单选题public class Score implements Comparable { private int wins, losses; public Score(int w, int 1) { wins = w; losses = 1; } public int getWins() { return wins; } public int getLosses() { return losses; } public String toString() { return “”; } // insert code here } Which method will complete this class?()A public int compareTo(Object o) {/*mode code here*/}B public int compareTo(Score other) {/*more code here*/}C public int compare(Score s1,Score s2){/*more code here*/}D public int compare(Object o1,Object o2){/*more code here*/}