更多"已知有下面的类说明: public class Test4 p"的相关试题:
[单项选择]已知有下面的类说明:
public class Test4
private float f=1.0f;
int m=12;
static int n=1;
public static void main(String args[])
Test4 e=new Test4( );
在main( )方法中,下面哪个的使用是正确的 ( )
A. f
B. this.n
C. Test4.m
D. Test4.f
[单项选择]已知有下面的类说明:
pubic class Test4
private float f=1.0f;
int m=12;
static int n=1;
public static void main(String args[])
Test4 e=new Test4( );
在main( )方法中,下面( )使用是正确的。
A. f
B. this.n
C. Test4.m
D. Test4.f
[填空题]以下程序的输出结果为______。
public class Tom
private float weight;
private static String name;
public void setWeight(float weight)
this.weight = weight;
private void out______
System.out.println(name + "体重:" + weight + "斤");
public static void main(String[] args)
Tom.name = "汤姆猫";
Tom cat = new Tom______;
cat.setWeight(20);
cat.out______;
[单项选择]执行下面程序段,屏幕上将输出( )。
public class Test
private int x=10,y=20;
public Test (int x,int y)
System.out.println (x+this.x);
System.out.println (y+y);
public static void main (String[] args)
Testt= new Test(30,50);
A. 无输出
B. 20
C. 40
D. 40
[单项选择]
阅读下面实现堆栈类并发控制的部分代码
public class DataStack{
private int idx=0;
private int[]data=new int[8];
public void push(int i){
. ________________{
data[idx]=i;
idx + +;
}
}
}
…… }
在程序下画线处填入正确选项是()
A. synchronized
B. synchronized(this)
C. synchronized()
D. synchronized(idx)
[单项选择]阅读下面程序
public class Test4
public static void main (String args[])
int i=10, j=3;
float m=213.5f,n=4.0f
System.out.printIn (i%j);
System.out.printIn (m%n);
程序运行的结果是______。
A. 1.0和1.5
B. 1和1.5
C. 1.0和2.5
D. 1和2.5
[简答题]指出下面代码中不合法的地方,并指明原因。
class Class26
float u;static float v;
static void setuv(boolean f)
u=sm(f);
v=rm(! f);
float rm(boolean f)
return f u:v;
static float sm(boolean f)
return f u:v;
[单项选择]下列程序的运行结果是() public class test{ private String[] data={“10”,“10.5”}; public void fun(){ double s=0; for(int i=0;i<3;i++){ try{ s=s+Integer .parseInt(data[i]); }catch(Exception e){ System.out.print(“errorl:”+data[i]); } } } public static void main(String[]args){ try{ testd=new test(); d .fun(); }catch(Exception e){ System.out.printIn(“error2”); } } }
A. errorl:10.5
B. error2
C. errorl:10.5 error2
D. 以上都不对
[填空题]以下程序的输出结果为______。
public class Course
private String cNumber;
private String cName;
private int cUnit;
public Course(String number, String name, int unit)
cNumber = number;
cName = name;
cUnit = unit;
public void printCourseInfo______
System.out.println("课程号:" + cNumber + " 课程名:" + cName + " 学分:" + cUnit);
class CourseTest
public static void main(String[] args)
Course c;
c = new Course("101", "ASP", 3);
c.printCourseInfo______;
[简答题]class point
private:
int x,y;
public:
point(int,int);
point(point&);
;
point::point(int a,int b)
x=a;
______=b;
point::point(______)
x=z.x;
y=z.y;
void main( )
point p1(2,3);
point p2(p1);
[简答题]
【代码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;
}
}
[单项选择]
Recession Fuels Shift from Private to Public Schools
When the family budget started feeling the recession’s pinch last year, Angela Allyn and her photographer husband, Matt Dinnerstein, pulled their three kids out of Chicago-area private schools and enrolled them in Evanston, m., public schools.
It has been a challenging transition: Maya, 16, now a high school sophomore, doesn’t like crowds--and her high school is as big as a small college," her mother says. Though Maya is learning a lot in the "amazing" science program, she’s also hoping to leave the crowds behind by doubling up on coursework, graduating by the end of junior year "and then going and doing interesting things," Allyn says. Her younger children face their own challenges, from bullying to sheer boredom.
The transition also has been an education for Maya’s parents, who say they had "no choice" in the struggling economy but to switch to public schools.
They’re saving about $20,0
A. doubtful
B. stunned
C. confused
D. uneasy