下面程序是关于位运算符的使用。请在程序的每条横线处填写一个位运算符,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填人适当的位运算符。public class BitOperator{public static void main(String args[]){int a=9; //二进制数1001int b=15;//二进制数1111int c=8; //二进制数1000int d,e,f,g,h;d=a__________b;//二进制数1001,也就是十进制数9e=a|b;//二进制数1111,也就是十进制数15f=a__________b;//二进制数0110,也就是十进制数6g=a<<2;//9×4=36h=c__________1;//8/2=4System.out.println("d="+d);System.out.println("e="+e);System.out.println("f="+f);System.out.println("g="+g);System.out.println("h="+h);}}

下面程序是关于位运算符的使用。请在程序的每条横线处填写一个位运算符,使程序的功能完整。

注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填人适当的位运算符。

public class BitOperator{

public static void main(String args[]){

int a=9; //二进制数1001

int b=15;//二进制数1111

int c=8; //二进制数1000

int d,e,f,g,h;

d=a__________b;//二进制数1001,也就是十进制数9

e=a|b;//二进制数1111,也就是十进制数15

f=a__________b;//二进制数0110,也就是十进制数6

g=a<<2;//9×4=36

h=c__________1;//8/2=4

System.out.println("d="+d);

System.out.println("e="+e);

System.out.println("f="+f);

System.out.println("g="+g);

System.out.println("h="+h);

}

}


相关考题:

接口是抽象方法和常量的集合,是一种特殊的抽象类。下面的程序是对接口的操作,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________MyInterface{public static int NUM=100;public abstract void print();}public class ClassName___________MyInterface{public void print(){System.out.println(NUM);}public static void main(String args[]){__________________________obj .print();}}

下面的程序是用do-while语句计算10的阶乘。请在程序的每条横线处填写1个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容;仅在横线处填入适当的语句。源程序文件代码清单如下:public class DoWhileLoop{public static void main(______){int n=10;long result=1;do{_____;}_____;System.out.println("10的阶乘为:"+result);}}

下面程序执行后,输出结果为:true请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class TestStringCompare{{public static void main(String ____________________ args){char charl[]={'t','e','s','t'};char char2[]={'t','e','s','t','1'};String str1=new String(___________________);String str2=new String(char2,0,4);System.out.println(__________________________);}}

下面程序的功能是将数组array下标为奇数的元素相乘(数组的位置是从0开始的),并将乘积存放到变量 total中。请在程序的每条横线处填写—个位运算符,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序代码文件清单如下:public class JiShuJi{public static void main(String args[]){int array[ ]={1,2,3,5,7,9};long total=for(int i=1;i<=______;i++){______;i++;}System.out.println(total);}}

下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。____________________public class TestKeyBoardInPut{public static void main(String[] args){String yourname=JOptionPane. ____________________ ("What is your name?");System.out.println("Hello"+yourname);____________________.exit(0);}}

下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:public class DoWhileLoop{public static void main(________){int n=10;long result=1;do{_______________}______________System.out.println("10的阶乘为: "+result);}}

下面的程序的功能是求1~100的奇数的和及该和的平均值。请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class SumAndAve{public static void main(String args[]){int count = 0, sum = 0, ave= 0;for (int i = 1; i<= 100; ______)if(______)continue;else{______sum=sum+i;}ave= sum/count;System.out.println( "sum="+sum);System.out.println( "ave="+ave);}}

下面是关于字符界面基本输入输出的程序,请在程序的每条横线处填写一个语句,使程序的功能完整。注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。______________________public class SimpleCharInOut{public static void main(String args[]){char c=" ";System.out.println("Enter a character please: ");try{____________________//接受用户键盘输入的字符并保存在变量c中}catch(________________________e){}System.out.println("You've entered character "+c);}}

下面的程序是求字符串的长度及每一个位置上的字符。请在每条横线处填写一条语句,使程序的功能完整。注意;请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。public class CharAtOp{public static void main(String args[ ]){String str="abcdef";int size=System.out.println("字符串str的长度为: "+size);for(int m=0;___________________m++){_______________________System.out.println("str中的第"+m+"个字符是: "+c);}}}