更多"下面程序是关于位运算符的使用。请在程序的每条横线处填写适当的语句,使程"的相关试题:
[简答题]下面程序是关于位运算符的使用。请在程序的每条横线处填写一个位运算符,使程序的功能完整。
注意:请勿改动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( )主方法和其他已有的语句内容,仅在横线处填入适当的位运算符。
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);
}
}
[单项选择]下面关于位运算符的叙述,正确的是______。
A. &表示“按位与”的运算
B. #表示“按位异或”的运算
C. ~表示“按位异或”的运算
[简答题]请在下面程序中的每条横线处填写一个语句,使程序的功能完整。程序的输出结果为:
TIME=1867
b=9
i=123
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
import java.io.*;
public class DataType{
public______________void main(String args[])
{
byte b;
int i;//定义变量i为int类型
___________________________ //定义常量TIME为整型,且值为1867
i=123;//给变量i赋值,该值为十进制的123
__________________________________//给变量赋值,改值为,八进制的11,十进制的9
System.out.println("TIME”+TIME);
System.out.println("b="+b);
System.out.println("i="+i);
}
}
[简答题]请在下面程序中的每条横线处填写一个语句,使程序的功能完整。程序的输出结果为:
TIME=1867
b=9
i=123
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件代码清单如下:
import java.io.*;
public class DataType
public ______ void main(String args[])
byte b;
int i;//定义变量i为int类型
______//定义常量TIME为整型,且值为1867
i=123;//给变量i赋值,该值为十进制的123
______//给变量赋值,改值为八进制的11,十进制的9
System.out.println("TIME"+TIME);
System.out.println("b="+b);
System.out.println("i="+i);
[简答题]下面程序执行后,输出结果为: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(__________________________);
}
}
[填空题]通过实现Rmmable接口创建线程,请在下面横线处填写代码完成此程序。
public class ThreadTest
{
public static void main(String args [])
{
Thread testObj1 = new Thread (new Hello ( ));
Thread testObj2 = new Thread (new Hello ( ));
testObj 2.start ( );
}
}
class Hello implements Runnable
{
int j;
public void run( )
{
System.out.println("Hello" + j ++);
}
}
[简答题]下面是关于字符界面基本输入输出的程序,请在程序的每条横线处填写一个语句,使程序的功能完整。
注意:请勿改动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);
}
}
[简答题]下面程序的功能是输出字符串“HGPEDCBA”, 请在程序的每条横线处填写一个适当的语句,使程序的功能完整。
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
import java.io.*;
public class InputString
public static void main(String args[ ])
String stringname= new _______________ ("ABCDEFGH");
for(int i= _______________ i>=0;i--)
System.out.println(String.valueOf(stringname.________________));
[简答题]下面的程序的功能是简单的进行键盘输入测试,请在程序的每条横线处填写一个语句,使程序的功能完整。
注意:请勿改动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);
[简答题]通过实现Runnable接口创建线程,请在下面横线处填入代码完成此程序。
注意:不改动程序结构,不得增行或删行。
class ThreadTest implements Runnable
{
Thread thrObj;
public static void main(String args[])
{
System.out.println("这是一个通过实现接口创建线程的例子");
ThreadTest testObj=new ThreadTest( );
testObj.create( );
}
public void create( )
{
if(thrObj= =null)
{
thrObj=new Thread(this,"myThread");
______
}
}
public void run( )
{
System.out.println("Thread"+throbj.getName( )+":"+"在运行!");
}
}
[填空题]从对象流中读取对象,请在下面横线处填写代码完成此程序。
import java.util. *;
import java. io. *;
public class UnSerializeDate
{
date d = null;
UnSerializeDate ( )
{
try
{
FileInputStream f1 = new FileInputStream("date.ser");
d = (Date) s. readobject ( );
f1,close( );
}
catch (Exceptin e)
{
e. printStackTrace ( );
}
}
public static main(String args [] )
{
System.out.println("The date read is: "+ a.d.toString( ));
}
}
[简答题]下面的程序的功能是求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);
}
}