![](https://static.youtibao.com/asksite/comm/h5/images/m_q_title.png)
下面属于public void demo(){...}的重载函数的选项是()。
A、private void demo(){...}
B、public int demo(){...}
C、public void demo2(){...}
D、public int demo(intm,floatf){...}
![](https://static.youtibao.com/asksite/comm/h5/images/solist_ts.png)
A、private void demo(){...}
B、public int demo(){...}
C、public void demo2(){...}
D、public int demo(intm,floatf){...}
A.编译失败
B.编译通过,没有结果输出
C.输出:除法正常运行
D.输出:除数不能为0
A.0
B.1
C.2
D.4
A.public abstract void method(){}
B.public void method() extends abstract
C.public abstract void method()
D.public abstract method()
A.public static void main ()
B.public static void main (String args[ ])
C.public static int main (String [ ] args)
D.public void main (String args[ ])
A.public static void main()
B. public static void main(String args[])
C. public Static int main(String[] arg)
D. public :void main(String args[])
A、x:5 x:5
B、x:5
C、编译有错
D、以上答案都不对
下面程序的主线程创建10个线程,它们都取变量的值,经累加后,将新值存回到变量且要求结果正确。
class MyResourceClass
{
int IntegerResource;
MyResourceClass(){IntegerResource=0;}
public int getInfo(){return IntegerResource;}
public void putInfo(int info){IntegerResource=info;}
()Void sumResource(int q)
{
int LocalInteger;
LocalInteger=getInfo();
LocalInteger+=q;
putInfo(LocalInteger);
}
}
class MyMultiThreadClass implements Runnable
{
MyResourceClass UseInteger;
MyMultiThreadClass(MyResourceClass mrc)
{
UseInteger=mrc;
}
public void run()
{
for(int i=0;i<100;i++)
{
UseInteger.sumResource(50);
}
}
}
public class Class30
{
public static void main(String[] args)
{
MyResourceClass mrc=new MyResourceClass();
Thread aThreadArray[]=new Thread[10];
System.out.println(mrc.getInfo());
System.out.println("wait...");
for(int i=0;i<10;i++)
{
aThreadArray[i]=new Thread(new MyMultiThreadClass(mrc));
aThreadArray[i].();
}
whileLoop;
while(true)
{
for(int i=0;i<10;i++)
if(aThreadArray[i].isAlive())continue whileLoop;
break;
}
System.out.println("jieguo="+mrc.getInfo());
}
}
假设test类运行于多线程环境下,那么关于A处的同步下面描述正确的是? ()
public class Test {
List list= new java.util.ArrayList();
public void test() {
synchronized (list) { // --A
list.add(String.valueOf(System.currentTimeMillis()));
}
}
}
A.test方法中必须增加synchronized
B.Test类为singleton时有必要增加synchronized
C.test方法中没有必要增加synchronized
D.Test类为singleton时也没有必要增加synchronized
根据下面类中Reverse 函数成员的原型和注释写出它的类外定义。
class AA {
int* a;
int n;
int MS;
public:
void InitAA(int aa[], int nn, int ms) {
if(nn>ms) {cout<< "Error!"<< endl; exit(1);}
MS=ms;
n=nn;
a=new int[MS];
for(int i=0; i
}
AA* Reverse(); // 对于调用该函数的对象,将其a 数组中前n 个
// 元素值按相反的次序排列,返回指向该对象的指针。
};
A.public void mouseMoved(MouseEvent)
B.public boolean mouseMoved(MouseEvent)
C.public void mouseMoved(MouseMotionEvent)
D.public boolean MouseMoved(MouseMotionEvent)
A.public final writeLog(String msg)
B.public final abstract void writeLog(String msg)
C.public static final void writeLog(String msg)
D.public static abstract void writeLog(String msg)