![JAVA練習(xí)題含答案ANSWERSTOPRACTICE_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f1.gif)
![JAVA練習(xí)題含答案ANSWERSTOPRACTICE_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f2.gif)
![JAVA練習(xí)題含答案ANSWERSTOPRACTICE_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f3.gif)
![JAVA練習(xí)題含答案ANSWERSTOPRACTICE_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f4.gif)
![JAVA練習(xí)題含答案ANSWERSTOPRACTICE_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f/6a7564bf-cfcd-4e2d-9ad8-5e60b245be4f5.gif)
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、Multiple ChoiceIWhich operator is used to con cate nate two stri ngs?(a+(b-(c*(d/An swer:A(see page352Which operator returns the rema in der of in teger divisio n?(a%(b/ (c* (dnone of the aboveAn swer:A(see page263What is the value of the variable c in the statements that follow?Stri ng phrase="
2、;Make hay while the sun is shi nin g." char c=phrase.charAt(10;(aw(bh (ci(dNone of the aboveAn swer:B(see page404The escape seque nee the represe nts the n ew-l ine character is:(ar(bt(c n(dAn swer:C(see page435The syn tax that declares a Java n amed con sta nt n amed SALES_TAX is:(adouble SALE
3、S_TAX=7.50;(bpublic double SALES_TAX=7.50;(cpublic static double SALES_TAX=7.50;(dpublic static final double SALES_TAX=7.50;An swer:D(see page476ln Java,a block comme nt is delimited by:(a*/*(b/*/*(c/*/(d*/*/An swer:C(see page507To mark a block comme nt for in clusi on in the Javadoc docume ntatio n
4、,the block mustbe delimited by:(a/*/(b*/*/(c*(d*/*/An swer:A(see page508Valid arguments to the System.out oject ' s printin method include:(a “Anything with double quotes”(bStri ng variables(cVariables of type int(dAll of the aboveAn swer:D(see page599Which stateme nt or group of stateme nts pro
5、duces the output:Java program ming isfun!(aSystem.out.pri nt(Java program ming;System.out.pri nt(is fun!;(bSystem.out.println(Java programming is fun!;(cSystem.out.pri ntl n(Java program ming;System.out.pri ntl n(“ is fun! ”;(dSystem.out.pri nt(Java program mingSystem.out.pri ntl n(“ is fun! ”;An sw
6、er:D(see page6010If a hyphen is added after the%in a format specifier,the output will be(aLeft justified(bRight justified(cCe ntered(dNone of the aboveAn swer:A(see page6411The statement:System.out.printf("%6.2f",597.7231;displays:(a597.723(b597.72(C000597.72(dNone of the aboveAn swer:B(se
7、e page6412The Java method printf is based on theIan guage.(aPascal(bC+(cC(dADAAn swer:C(see page6713The class NumberFormat allows you to specify a con sta nt represe nti ng which country ' scurre ncy format should be used.To use this con sta nt you must import:(ajava.util Locale(bjava.util.Curre
8、 ncy(cjava.util.Properties(dN one of the above.An swer:A(see page7114Sta ndard code libraries in Java are called:(aMethods(bClasses(cPackages(dStateme ntsAn swer:C(see page7215What Java package in eludes the class Scanner?(aawt(bsw ing(cio(dutilAn swer:D(see page78True/FalseObjects of type String ar
9、e strings of characters that are written within single quotes.An swer:False(see page342ln Java,Stri ngs are immutable objects .Im mutable objects can be cha nged.An swer:False(see page443An adva ntage of using the Uni code character set is that it easily han dles Ian guages other tha n En glish.An s
10、wer:True(see page444Java uses the ASCII character set.An swer:False(see page44lEfficie ncy is lost in importi ng the en tire package in stead of importi ng the classesyouuse.An swer:False(see page732Every Java program automatically imports the java.util package.An swer:False(see page733The newline c
11、haracter is represe nted asi'.An swer:True(see page614The method printf is used the same way as the method printin but has the added featurethat allows you to add formatting instructions.An swer:False(see page615The printf method can be used to output multiple formatted values.An swer:True(see p
12、age646The Scanner class has a method next that allows an entire line of string text to be read.An swer:False(see page807Echo ing in put is good program ming practice because it can reveal problems in thein put.An swer:True(see page80Short An swer/Essay1How is the%(modulusoperator used?What is the co
13、m mon use of the modulusoperator?An swer:The modulus operator is used to retur n the rema in der in in teger divisi on.For example,the modulus operator is commonly used to determine if a number is an eve n or an odd value.2What is the output of the followi ng Java stateme nts?/Stri ng method example
14、sString str="Java Programmi ng!"System.out.pri ntl n( str.equals("Java Program min g!"System.out.pri ntln( str.toLowerCase(;System.out.pri ntln( str.toUpperCase(;System.out.pri ntln( str.substri ng(5,8;System.out.pri ntln( str.last In dexOf("m"An swer:truejava program m
15、ing!JAVA PROGRAMMING!Pro123 Write a Java stateme nt to access the 7th character in the String variable myStri ng and place it in the char variable c. Answer: c = myString.charAt(6; 4 Write a Java stateme nt to determ ine the len gth of a string variable called in put. Store the result in an in teger
16、 variable called strLe ngth. An swer: int strLe ngth = in put.le ngth(; 5 Write ONE Java stateme nt to display your first and last n ame on two separate lin es. An swer: System.out.pri nt("WallynWon ders" 6 Write a complete Java con sole applicati on that prompts the user for two numbers,
17、multiplies the numbers, and then displays the result to the user. An swer: import java.util.Sca nner; public class Con soleMultiply public static void main( Stri ng args /Create the sca nner object for con sole in put Scanner keyboard =new Scanner(System.in; /Prompt the user for the first number Sys
18、tem.out.print("Enter the first in teger: " /Read the in put int firstNumber = keyboard .n extI nt(; /Prompt the user for the sec ond nu mber System.out.pri nt("E nter the sec ond in teger:"/Read the sec ond nu mber int sec on dNumber = keyboard .n extI nt(; System.out.pri ntln (f
19、irstNumber + "*" + sec on dNumber + " is " + firstNumber * sec on dNumber; 7 Write a Java stateme nt to create and in itialize a Scanner object n amed in put. An swer: Scanner in put = new Scann er(System.i n; 8 Con sider the followi ng code snippet. int i = 10; int n = i+%5; 1)
20、What are the values of i and n after the code is executed? An swer: i is 11, and n is 0. 2 What are the final values of i and n if in stead of using the postfix in creme nt operator (i+, you use the prefix versi on (+i? An swer: i is 11, and n is 1. 9 Program ming projects : questio n 2 and 3 (see p
21、age 93 import java.util.Scanner; public class Question2 public static void main(String args / Variable declarati ons Scanner scan = new Scann er(System.i n; Stri ng first; Stri ng last; System.out.pri ntl n("E nter your first n ame:" first = sca n.n extL in e(;System.out.pri ntln ("E
22、nter your last n ame:" last = sca n.n extL in e(; System.out.pri ntl n(first + " " + last + " turned to Pig Latin is:" / First convert first name to pig latinStri ng pigFirstName = first.substri ng(1,first.le ngth( + first.substri ng(0,1 + "ay" / Then capitalize fi
23、rst letter pigFirstName = pigFirstName.substring(0,1.toUpperCase( + pigFirstName.substring(1,pigFirstName.length(; / Repeat for the last name String pigLastName = last.substring(1,last.length( + last.substring(0,1 + "ay" / Then capitalize first letter pigLastName = pigLastName.substri ng(0,1.toUpperCase( + pigLastName.substri ng(1,pigLastName .len gth(; System.out.pri ntl n(
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 ISO 4892-4:2024 EN Plastics - Methods of exposure to laboratory light sources - Part 4: Open-flame carbon-arc lamps
- 【正版授權(quán)】 ISO 21068-4:2024 EN Chemical analysis of raw materials and refractory products containing silicon-carbide,silicon-nitride,silicon-oxynitride and sialon - Part 4: XRD metho
- 【正版授權(quán)】 ISO 13506-1:2024 EN Protective clothing against heat and flame - Part 1: Test method for complete garments - Measurement of transferred energy using an instrumented manikin
- 2025年度嬰幼兒保育員職業(yè)資格認(rèn)證聘用合同
- 2025年度茶葉出口退稅代理服務(wù)合同-@-3
- 2025年度防盜門安裝工程安全生產(chǎn)責(zé)任合同
- 2025年度農(nóng)村土地征收補(bǔ)償安置協(xié)議
- 2025年度董事任期考核及聘任合同
- 2025年陳設(shè)藝術(shù)陶瓷制品項目發(fā)展計劃
- 動手實踐小班農(nóng)業(yè)勞動體驗計劃
- 部編版語文一年級下冊第一單元教材解讀
- 護(hù)士臨床護(hù)理組長
- 2025保安部年度工作計劃
- 土建、裝飾、維修改造等零星工程施工組織設(shè)計技術(shù)標(biāo)
- 寵物貓護(hù)理教學(xué)
- 高速公路養(yǎng)護(hù)作業(yè)安全培訓(xùn)內(nèi)容
- 2024年江蘇經(jīng)貿(mào)職業(yè)技術(shù)學(xué)院單招職業(yè)適應(yīng)性測試題庫
- 《大白菜種植栽培技》課件
- 北京工業(yè)大學(xué)《數(shù)據(jù)挖掘》2023-2024學(xué)年第一學(xué)期期末試卷
- 圖書借閱登記表
- 標(biāo)準(zhǔn)化機(jī)房改造方案
評論
0/150
提交評論