版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 杜絕校園欺凌共建和諧校園演講稿范文(3篇)
- 北京市海淀區(qū)2024-2025學(xué)年高二上學(xué)期9月月考 數(shù)學(xué)試題(含解析)
- DB12-T 1110-2021 企業(yè)開(kāi)辦登記規(guī)范
- 貢獻(xiàn)社會(huì)主題班會(huì)教案
- 上海市市轄區(qū)(2024年-2025年小學(xué)五年級(jí)語(yǔ)文)統(tǒng)編版小升初模擬((上下)學(xué)期)試卷及答案
- 上海市縣(2024年-2025年小學(xué)五年級(jí)語(yǔ)文)統(tǒng)編版專題練習(xí)(上學(xué)期)試卷及答案
- 浙江省臺(tái)州市臺(tái)州十校聯(lián)考2024-2025學(xué)年高一上學(xué)期11月期中日語(yǔ)試題含答案
- 人教版九年級(jí)語(yǔ)文上冊(cè)教案全集
- 遼寧省沈陽(yáng)市沈河區(qū)沈陽(yáng)市第七中學(xué)協(xié)作體2024-2025學(xué)年八年級(jí)上學(xué)期期中地理試卷(含答案)
- 廣東省揭陽(yáng)市2025屆高三上學(xué)期第一次月考數(shù)學(xué)試題(含答案)
- 中醫(yī)基礎(chǔ)論述題
- 二 《學(xué)習(xí)工匠事跡 領(lǐng)略工匠風(fēng)采》(教學(xué)設(shè)計(jì))-【中職專用】高二語(yǔ)文精講課堂(高教版2023·職業(yè)模塊)
- 工程項(xiàng)目建設(shè)程序
- 中小學(xué)生勞動(dòng)教育的跨學(xué)科融合案例
- 分子結(jié)構(gòu)與化學(xué)性質(zhì)的關(guān)系
- 醫(yī)院內(nèi)肺炎預(yù)防與控制標(biāo)準(zhǔn)操作規(guī)程
- 道路(光彩工程)亮化施工投標(biāo)方案(技術(shù)方案)
- 2023年房地產(chǎn)估價(jià)師考試完整真題及答案解析
- 第14課 推進(jìn)綠色發(fā)展
- 山東省泰安市新泰市2023-2024學(xué)年五年級(jí)上學(xué)期期中語(yǔ)文試卷
- 《機(jī)械設(shè)計(jì)》課程思政教學(xué)案例(一等獎(jiǎng))
評(píng)論
0/150
提交評(píng)論