多选题class BaseClass{ private float x= 1.0f; protected void setVar (float f) {x = f;} } class SubClass extends BaseClass { private float x = 2.0f; //insert code here 16. } Which two are valid examples of method overriding?()AVoid setVar(float f) {x = f;}BPublic void setVar(int f) {x = f;}CPublic void setVar(float f) {x = f;}DPublic double setVar(float f) {x = f;}EPublic final void setVar(float f) {x = f;}FProtected float setVar() {x=3.0f; return 3.0f; }
多选题
class BaseClass{ private float x= 1.0f; protected void setVar (float f) {x = f;} } class SubClass extends BaseClass { private float x = 2.0f; //insert code here 16. } Which two are valid examples of method overriding?()
A
Void setVar(float f) {x = f;}
B
Public void setVar(int f) {x = f;}
C
Public void setVar(float f) {x = f;}
D
Public double setVar(float f) {x = f;}
E
Public final void setVar(float f) {x = f;}
F
Protected float setVar() {x=3.0f; return 3.0f; }
参考解析
解析:
暂无解析
相关考题:
已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?() A.private void fun( int n ){ //...}B.void fun ( int n ){ //... }C.protected void fun ( int n ) { //... }D.public void fun ( int n ) { //... }
已知如下类说明: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // 程序代码… } } 如下哪个使用是正确的?() A.t.fB.this.nC.Test.mD.Test.n
指出下面程序段中的错误,并说明出错原因【 】。class Location {int X, Y=20;protected:int zeroX, zeroY;int SetZero(int ZeroX, iht ZeroY);private:int length, height;public:float radius;void init(int initX,int initY);int GetX();Int GetY();};
已知有下列类的说明,则下列哪个语句是正确的?public class Test { private float f=1.0f; int m=12; static int n=1; public static void main(String arg[]) { Test t= new Test(); }}A.t.f;B.this. nC.Test.m;D.Test.f;
下列程序的执行结果是______。 include class Student { public: Student(int xx){x= 下列程序的执行结果是______。include<iostream.h>class Student{public:Student(int xx){x=xx;}virtual float calcTuition( );protected:int x;};float Studertt::calcTuition( ){return float(x*x);}class GraduateStudent:public Student{public:GraduateStudent(int xx):Student(xx){}float calcTuition( );};float Graduatestudent::calcTuition( ){return float(x*2);}void main( ){Student s(20);GraduateStudent gs(30);cout<<s.calcTuition( )<<" "<<gs.calcTuition( )<<endl;//计算学生s和研究生gs的学费}
有以下程序:include using namespace std;class A{private: int x,y;public: void se 有以下程序: #include <iostream> using namespace std; class A { private: int x,y; public: void set (int i,int j) { x=i; y=j; } int get_y() { return y; } }; class box { private: int length,width; A label; public: void set(int 1,int w, int s,int p) { length=1; width=w; label.set(s,p); } int get_area() { return length*width; } }; int main() { box small; small.set(2,4,1,35); cout<<small.get_area()<<end1; return 0; } 运行后的输出结果是( )。A.8B.4C.35D.70
12 一个给定的数值由左边开始升位到右边第 N 位,如00101 == 0100或者0001 00114 == 0011 0000请用 C 或者 C++或者其他 X86 上能运行的程序实现。----------------------------------------------------------------------------------------------------------------附加题(只有在完成以上题目后,才获准回答)In C++, what does "explicit" mean? what does "protected" mean?explicitC++ SpecificThis keyword is a declaration specifier that can only be applied toin-class constructor declarations. Constructors declared explicit will notbe considered for implicit conversions. For example:class X {public:explicit X(int); //legalexplicit X(double) { //legal // ... }};explicit X::X(int) {} //illegalAn explicit constructor cannot take part in implicit conversions. It canonly be used to explicitly construct an object. For example, with the classdeclared above:void f(X) {}void g(int I){f(i); // will cause error}void h(){X x1(1); // legal}The function call f(i) fails because there is no available implicitconversion from int to X.Note It is meaningless to apply explicit to constructors with multiplearguments, since such constructors cannot take part in implicit conversions.END C++ SpecificprotectedC++ Specific —protected: [member-list]protected base-classWhen preceding a list of class members, the protected keyword specifiesthat those members are accessible only from member functions and friends ofthe class and its derived classes. This applies to all members declared upto the next access specifier or the end of the class.When preceding the name of a base class, the protected keyword specifiesthat the public and protected members of the base class are protectedmembers of the derived class.Default access of members in a class is private. Default access of membersin a structure or union is public.Default access of a base class is private for classes and public forstructures. Unions cannot have base classes.For related information, see public, private, friend, and Table of MemberAccess Privileges.END C++ SpecificExample// Example of the protected keywordclass BaseClass {protected: int protectFunc();};class DerivedClass : public BaseClass{ public:int useProtect() { protectFunc(); } // protectFunc accessible fromderived class};void main(){BaseClass aBase;DerivedClass aDerived;aBase.protectFunc(); // Error: protectFunc not accessibleaDerived.protectFunc(); // Error: protectFunc not accessible in derivedclass } How do you code an infinite loop in C?
若有以下程序:include using namespace std;class A{private: int x;protected: int 若有以下程序: #include <iostream> using namespace std; class A { private: int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx () { return x; }; class B : protected A { public: void setvalue(int a, int b, int c) { setx (a); y=b; z=c; } void display() { cout<<getx ( ) <<", "<<y<<", "<<z<<", "<<end1; } }; int main () { B obj; obj.setvalue(5, 6, 7); obj.display ( ); return 0; } 程序运行后的输出结果是( )。A.产生语法错误B.7,6,5C.5,6,7D.7,5,6
下面程序中错误之处是 ______。 include classA{private:intxl;protected:intx2;publ 下面程序中错误之处是 ______。include<iostream.h>class A{private:int xl;protected:int x2;public:int x3;};class B: public A{private:int b1;protected:int b2;public:int b3;void disp(){cout<<x1<<b2<<end1;} //Avoid set(int i){x3=i;} //B};void main()B bb;bb. a3=10 //Cbb. b3=10 //D}
请找出下列程序中错误之处 ______。 include classA{private: intx1;protected: int 请找出下列程序中错误之处 ______。#include<iostream.h>class A{private:int x1;protected:int x2;public:int x3;};class B:public A{private:int y1;protected:int y2;public:int y3;void disp(){cout<<x1<<y1<<end1:} //Avoid set(int i) {x2=i;} //B};void main() {B bb;bb.x3=10; //Cbb.y3=10; //D}A.AB.BC.CD.D
若有以下程序:include using namespace std;class Base{private: int x;protected: i 若有以下程序: #include <iostream> using namespace std; class Base { private: int x; protected: int y; public: int z; void setx(int i) { x=i; int getx () { return x; } }A.1,2,3,4B.产生语法错误C.4,3,2,1D.2,3,4,5
1. class BaseClass { 2. private float x = 1.of; 3. protected float getVar() { return x; } 4. } 5. class SubClass extends BaseClass { 6. private float x = 2.Of; 7. // insert code here 8. } Which two are valid examples of method overriding when inserted at line 7?() A、 float getVar() { return x; }B、 public float getVar() { return x; }C、 public double getVar() { return x; }D、 protected float getVar() { return x; }E、 public float getVar(float f) { return f; }
public class MethodOver { public void setVar (int a, int b, float c) { } } Which two overload the setVar method?()A、 Private void setVar (int a, float c, int b) {}B、 Protected void setVar (int a, int b, float c) {}C、 Public int setVar (int a, float c, int b) (return a;)D、 Public int setVar (int a, int b, float c) (return a;)E、 Protected float setVar (int a, int b, float c) (return c;)
1. abstract class AbstractIt { 2. abstract float getFloat(); 3. } 4. public class AbstractTest extends AbstractIt { 5. private float f1 = 1.0f; 6. private float getFloat() { return f1; } 7. } What is the result?() A、 Compilation succeeds.B、 An exception is thrown.C、 Compilation fails because of an error at line 2.D、 Compilation fails because of an error at line 6.
Given: 1. public class Method Over { 2. public void set Var (int a, int b, float c) { 3. } 4. } Which two overload the set Var method()?A、 private void set Var(int a, float c, int b) {}B、 protected void set Var(int a, int b, float c) {}C、 public int set Var(int a, float c, int b) {return a:}D、 public int set Var(int a, int b, float c) {return a:}E、 protected float set Var(int a, int b, float c) {return c:}
abstract class abstrctIt { abstract float getFloat (); } public class AbstractTest extends AbstractIt { private float f1= 1.0f; private float getFloat () {return f1;} } What is the result? ()A、 Compilation is successful.B、 An error on line 6 causes a runtime failure.C、 An error at line 6 causes compilation to fail.D、 An error at line 2 causes compilation to fail.
public class SyncTest ( private int x; private int y; private synchronized void setX (int i) (x=1;) private synchronized void setY (int i) (y=1;) public void setXY(int 1)(set X(i); setY(i);) public synchronized Boolean check() (return x !=y;) ) Under which conditions will check () return true when called from a different class?A、 Check() can never return true. B、 Check() can return true when setXY is called by multiple threads. C、 Check() can return true when multiple threads call setX and setY separately. D、 Check() can only return true if SyncTest is changed to allow x and y to be set separately.
class BaseClass{ private float x= 1.0f; protected void setVar (float f) {x = f;} } class SubClass extends BaseClass { private float x = 2.0f; //insert code here } Which two are valid examples of method overriding?() A、 Void setVar(float f) {x = f;}B、 Public void setVar(int f) {x = f;}C、 Public void setVar(float f) {x = f;}D、 Public double setVar(float f) {x = f;}E、 Public final void setVar(float f) {x = f;}F、 Protected float setVar() {x=3.0f; return 3.0f; }
public class MethodOver { private int x, y; private float z; public void setVar(int a, int b, float c){ x = a; y = b; z = c; } } Which two overload the setVar method?()A、 void setVar (int a, int b, float c){ x = a; y = b; z = c; }B、 public void setVar(int a, float c, int b) { setVar(a, b, c); }C、 public void setVar(int a, float c, int b) { this(a, b, c); }D、 public void setVar(int a, float b){ x = a; z = b; }E、 public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }
用于定义类成员的访问控制权的一组关键字是()。A、class,float,double,publicB、float,boolean,int,longC、char,extends,float,doubleD、public,private,protected
多选题Given: 1. public class Method Over { 2. public void set Var (int a, int b, float c) { 3. } 4. } Which two overload the set Var method()?Aprivate void set Var(int a, float c, int b) {}Bprotected void set Var(int a, int b, float c) {}Cpublic int set Var(int a, float c, int b) {return a:}Dpublic int set Var(int a, int b, float c) {return a:}Eprotected float set Var(int a, int b, float c) {return c:}
多选题public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()Apublic class Circle implements Shape { private int radius; }Bpublic abstract class Circle extends Shape { private int radius; }Cpublic class Circle extends Shape { private int radius; public void draw(); }Dpublic abstract class Circle implements Shape { private int radius; public void draw(); }Epublic class Circle extends Shape { private int radius;public void draw() {/* code here */} }Fpublic abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
多选题public class MethodOver { private int x, y; private float z; public void setVar(int a, int b, float c){ x = a; y = b; z = c; } } Which two overload the setVar method?()Avoid setVar (int a, int b, float c){ x = a; y = b; z = c; }Bpublic void setVar(int a, float c, int b) { setVar(a, b, c); }Cpublic void setVar(int a, float c, int b) { this(a, b, c); }Dpublic void setVar(int a, float b){ x = a; z = b; }Epublic void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }
多选题class BaseClass{ private float x= 1.0f; protected void setVar (float f) {x = f;} } class SubClass extends BaseClass { private float x = 2.0f; //insert code here } Which two are valid examples of method overriding?()AVoid setVar(float f) {x = f;}BPublic void setVar(int f) {x = f;}CPublic void setVar(float f) {x = f;}DPublic double setVar(float f) {x = f;}EPublic final void setVar(float f) {x = f;}FProtected float setVar() {x=3.0f; return 3.0f; }
多选题1. class BaseClass { 2. private float x = 1.of; 3. protected float getVar() { return x; } 4. } 5. class SubClass extends BaseClass { 6. private float x = 2.Of; 7. // insert code here 8. } Which two are valid examples of method overriding when inserted at line 7?()Afloat getVar() { return x; }Bpublic float getVar() { return x; }Cpublic double getVar() { return x; }Dprotected float getVar() { return x; }Epublic float getVar(float f) { return f; }
多选题class BaseClass{ private float x= 1.0f; protected void setVar (float f) {x = f;} } class SubClass exyends BaseClass { private float x = 2.0f; //insert code here 8. } Which two are valid examples of method overriding?()AVoid setVar(float f) {x = f;}BPublic void setVar(int f) {x = f;}CPublic void setVar(float f) {x = f;}DPublic double setVar(float f) {x = f;}EPublic final void setVar(float f) {x = f;}FProtected float setVar() {x=3.0f; return 3.0f; }
单选题1. abstract class AbstractIt { 2. abstract float getFloat(); 3. } 4. public class AbstractTest extends AbstractIt { 5. private float f1 = 1.0f; 6. private float getFloat() { return f1; } 7. } What is the result?()A Compilation succeeds.B An exception is thrown.C Compilation fails because of an error at line 2.D Compilation fails because of an error at line 6.
单选题abstract class abstrctIt { abstract float getFloat (); } public class AbstractTest extends AbstractIt { private float f1= 1.0f; private float getFloat () {return f1;} } What is the result?()A Compilation is successful.B An error on line 6 causes a runtime failure.C An error at line 6 causes compilation to fail.D An error at line 2 causes compilation to fail.