- 1
- 0
- 约4.53千字
- 约 3页
- 2025-04-02 发布于广东
- 举报
1.DefineaJavamethodtoprintthenumberofvowelcharacterandthenumberofspacesinagiven
string.
Vowelsincludea,A,e,E,i,I,o,O,u,U.
给定一个字符串,分别统计其中所包含的元音的个数和空格的个数。
元音:a,A,e,E,i,I,o,O,u,U。
2.Defineamethodtocollectthecommonelementsintwoarraysofintegers.
int[]getCommonElements(int[]arr1,int[]arr2)
编程返回由两整型数组arr1和arr2中共同的元素组成的数组。
int[]getCommonElements(int[]arr1,int[]arr2)
3.DefineaBankAccountclass,whichcontains:
(1)Bankaccountattributes:username,accountnumber,andbalance.
(2)Constructionmethods:atleasttwoconstructionmethods,callingmulti-parameterconstruction
methodstodefineno-parameterconstructionmethods.Definethegetmethodandsetmethodof
eachproperty.
(3)Definemethods:deposit(floatamount)withdraw(floatamount).OverridethetoString()
methodtooutputaccountandbalanceinformation.
(4)Instantiatethisclassinthemain()method,andcallthetoString()methodtocompletetheoutput
ofvariousinformation.
编写一个BankAccount类表示银行账号,该类中包含:
(1)银行账号信息:用户名name、账号number、余额balance。
(2)构造方法:至少两种构造方法,利用多参的构造方法定义无参的构造方法。
定义各属性的get方法和set方法。
(3)定义示例方法:存款deposit(amount)方法、取款withdraw(amount)两个实例方法。重写
toString()方法,输出账号和余额信息。
(4)在main()方法中实例化这个类,调用toString()方法完成各项信息的输出。
4.(1)DesigntheabstractclassesCar,includingfields:carId,carName;amulti-parameter
constructor;theget-methodofeachattribute,theabstractgetCapacity();
(2)DesigninterfaceIHumanNum,includinggetIHumanNum()andsetIHumanNum()methods.
(3)DesignsubclassePassagecarinheritstheCarclassandimplementstheIHumanNuminterface,
definetheprivateattributeinthumanNum.Thisconstructorinheritsthesuperconstructorand
initializetheattributehumanNum.OverridethemethodgetCapacity():printNumberofpeopleon
board:+humanNum+person;
(4)Designthemain()method.Anarraynamedcarsisusedtostor
您可能关注的文档
- 2023年全国义务教育优质均衡质量监测(小学科学四年级)试题汇总.docx
- 四年级下册单元作文教学支架(1-8单元).docx
- 多元函数微分法及应用 (1).pdf
- 岩土力学实验.pdf
- 2020-2021第1学期《离散数学》a卷19级信计,应数大数据专业.pdf
- 多元函数微分法及应用.pdf
- 工程化学实验报告.pdf
- 月考同步练习试题.pdf
- 河北邢台市2025-2026学年高二上学期2月期末语文试题(含解析).docx
- 河北邢台市2025-2026学年高一上学期2月期末物理试题(含解析).docx
- 河北盐山中学等校2025-2026学年上学期高三一模化学试卷(含解析).docx
- 河北正定中学2025-2026学年高一上学期期末考试物理试卷(含解析).docx
- 河北张家口市怀安县2025-2026学年第一学期期末教学综合评价八年级地理试卷(含解析).docx
- 河南安阳市殷都区2025-2026学年第一学期期末教学质量检测七年级地理试卷(含解析).docx
- 河南安阳市滑县2025一2026学年第一学期期末学业质量监测八年级地理试题(含解析).docx
- 河南安阳市林州市2025-2026学年上学期期末考试高一政治试题(含解析).docx
- 河南焦作市武陟县第一中学2025-2026学年高一上学期1月月考语文试卷(含解析).docx
- 河南济源市2025-2026学年上学期期末学业质量调研七年级历史试卷(含解析).docx
- PICC导管并发症的紧急处理与护理.pptx
- 河南鹤壁市2025-2026学年高二上学期期末考试生物试题(含解析).docx
原创力文档

文档评论(0)