编程基础专项练习
编程基础专项练习 20 题:进制、位运算、递归、内存管理、Java 基础等。(题目与解析为参考(自拟),非官方标准答案。)
第 1 / 20 题得分 0
第 1 题 · 单选
有一个装过食盐的瓶子,容积是 w,在食盐用完之后,还有一些食盐粉末(体 积可以忽略)残留在瓶子壁上。现在要把该瓶子改装糖,给你 u 体积的纯净
水,用来清洗该瓶子。在每次清洗之后,瓶子里会残留至少 v 体积的水(食盐 溶液,可以忽略盐的体积) 。假设
w>u>v,请问下述哪种方式使用这些纯净 水,能把瓶子洗得最干净______?
第 2 题 · 单选
Java程序中的类名称必须与存放该类的文件名相同。
第 3 题 · 单选
小数值1.5625的二进制表示是?
第 4 题 · 单选
下列运算符合法的是( )
第 5 题 · 单选
1100|1010,1001^1001,1001&1100分别为()
第 6 题 · 单选
关于异常处理机制的叙述正确的是()
第 7 题 · 单选
有如下算式成立,13*7=88,是采用()进制计算的。
第 8 题 · 单选
Given the following class:
public class Cat
{
long length;
public Cat(long l)
{
length = 1;
}
public static void main(String arg[])
{
Cat c1, c2, c3;
c1 = new Cat(10L);
c2 = new Cat(10L);
c3 = c2;
long m = 21L;
}
}
Which expression returns true?
第 9 题 · 单选
给定下列程序,那么执行printf("%d\n", foo(20, 13));的输出结果是()
int foo(int x, int y){
if (x <= 0 || y <= 0)
return 1;
return 3 * foo( x-6, y/2 );
}
第 10 题 · 单选
对于一个已经不被任何变量引用的对象,当垃圾回收器准备回收该对象所占用的内存时,将自动调用该对象的哪个方法()
第 11 题 · 单选
下面程序中, 输出是什么?
int fun(int x){
int count = 0;
while(x){
count++;
x = x &(x-1);
}
return count;
}
int main(){
cout << "fun(2015)=" << fun(2015)<<endl;
}
第 12 题 · 单选
public boolean returnTest()
{
try
{
return true;
}
catch (Exception e)
{
}
finally
{
return false;
}
}
以上代码返回值是什么?
第 13 题 · 单选
式子7*15=133成立,则用的是几进制?
第 14 题 · 单选
有关下述Java代码描述正确的选项是____。
public class TestClass {
private static void testMethod(){
System.out.println("testMethod");
}
public static void main(String[] args) {
((TestClass)null).testMethod();
}
}
第 15 题 · 单选
下面有关图片格式的对比,说法错误的是?
第 16 题 · 单选
下面程序的输出是:()
String x="fmn";
x.toUpperCase();
String y=x.replace('f','F');
y=y+"wxy";
System.out.println(y);
第 17 题 · 单选
3417 (34的17次方)对6取余, 结果是多少?
第 18 题 · 单选
下列关于继承的哪项叙述是正确的?
第 19 题 · 单选
分析下面的程序:
void GetMemory(char **p, int num)
{
*p = (char *)malloc(num);
}
int main()
{
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello");
free(str);
if (str != NULL)
{
strcpy(str, "world");
}
printf("\n str is %s", str);
getchar();
}
问输出结果是什么?
第 20 题 · 多选
以下哪些类是线程安全的()