阅读下面实现堆栈类并发控制的部分代码
public class DataStack{
private int idx=0;
private int[]data=new int[8];
public void push(int i){
. ________________{
data[idx]=i;
idx + +;
}
}
}
…… }
在程序下画线处填入正确选项是()
【代码6-1】
class Circle (1){
private (2) pxc;
public Circle( )pxc=new (3) ;
}
public void display( ){
pxc. (4) ;
}
]
【代码6-2】
public class Factory
public (5) getShapeInstance(int type){ //生成特定类实例
switch(type){
case 0: return new Point ( );
case 1: return new Rectangle ( ) ;
case 2: return new Line ( ) ;
case 3: return new Circle ( ) ;
default: return null;
}
}
public class App{
public static void main (String argv[] )
if (argv. length != l)
System. out.println ("error parameters !");
return;
}
inttype= (new Integer (argv[0])) .intValue (
Factory factory = new Factory ( ) ;
Shape s;
s=factory, (6)
if (s==null){
System.out.println ( "Error get instance !" )
return;
}
s.display ( ) ;
return;
}
}
我来回答: