下列程序的执行结果是______。 public class Test9 { public static void main(String[] args) { String s1 = new String("I am a girl"); String s2 = new String("I am a girl"); System.out.println (s1.equal (s2)); } }
A.true
B.假
C.I amgirl
D.都不正确
第1题:
下列程序的运行结果是______。
include<iostream.h>
class Base
{
public:
void f(int x){cout<<“Base:”<<x<<endl;}
);
class Derived:public Base
{
public:
void f(char*str){cout<<“Derived:”<<str<<endl;}
};
void main(void)
{
Base*pd=ne
第2题:
下面程序的结果是 ______。 #include<iostream.h> class A{ public: virtual void fun()=0{}; }; class B:public A{ public: void fun () {cout<< "new file" ;} }; class C: public A{ public: void fun (){cout<<"open file"<< " " } }; class D: public A{ public: void fun () {cout<< "save file\n" ;} }; void main() { A a,*p; B b; C c; D d; p=&c; p->fun (); p=&b; p->fun (); p=&d; p->fun(); }
A.new file open file save file
B.new file new file new file
C.编译出错
D.open file new file save file
第3题:
第4题:
以下程序的执行结果是______。
include<iostream.h>
class base
{
public:
virtual void who(){cout<<"base class"<<endl:}
};
class derrvel:public base
{
public:
void who(){cout<<"derivel class"<<endl:}
};
class derive2;public base
{
public:
void who() {cout<<"derive2 class"<<endl;}
};
void main()
{
base obj1,*P;
derive1 obj2;
derive2 obj3:
p=&obj1;
p->who();
p=&obj2:
p->who();
p=&obj3;
p->who();
}
第5题:
第6题:
main方法是Java应用程序执行的入口点,下面main方法的方法头合法的是()
A.public static void main()
B.public static void main(String[] args)
C.public static void Main(String[] args)
D.public static int main(String[] args)