Can you solve the question in this file
Microsoft Word - 201CS101_Major_Nov01, 2020.docx *Rename this downloaded question paper to your Student id. **After completion submit this word document on LMS. A. MCQs: Select the appropriate answer 10 Mar ks S. N. Questions Ans wer 1 Predict the output of the following code snippet: double a = 10; a += a + 1; System.out.println(a); a. 20 b. 21 c. 11 d. Syntax Error 2 boolean even = false; if (even = true) { System.out.println("It is even"); } a. The program has a compile error. b. The program has a runtime error. c. The program runs fine, but displays nothing. d. The program runs fine and displays It is even. 3 Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative? a. 1 < x="">< 100="" &&="" x="">< 0="" b.="" ((x="">< 100)="" &&="" (x=""> 1)) || (x < 0)="" c.="" ((x="">< 100)="" &&="" (x=""> 1)) && (x < 0)="" d.="" (1=""> x > 100) || (x < 0)="" 4="" consider="" the="" code="" segment="" below.="" if="" (="" gender="=" 1="" )="" {="" if="" (="" age="">= 65 ) ++seniorFemales; } This segment is equivalent to which of the following? a. if ( gender == 1 || age >= 65 ) ++seniorFemales; b. if ( gender == 1 && age >= 65 ) ++seniorFemales; c. if ( gender == 1 AND age >= 65 ) ++seniorFemales; d. if ( gender == 1 ^ age >= 65 ) ++seniorFemales; 5 Predict the output from the following code segment: boolean male = false; int age = 20; if( male ) if( age < 20="" )="" system.out.println("working="" man");="" else="" system.out.println("male="" student");="" else="" if(="" age=""> 20 ) System.out.println("Working Woman"); else System.out.println("Female Student"); a. Working Man b. Female Student c. Working Woman d. Male Student e. Compilation Error 6 Predict the output from following code snippet: int a = 0, b = 5; while( b-- > a++) System.out.println(a); a. Code will print 0 to 4 b. Code will print 0 to 5 c. Code will print 1 to 4 d. Code will print 1 to 3 7 Predict the output from following code for(char c = 'a' ; c < 'd'; c++) { system.out.print(c); } a. compilation error b. abcd c. 65666768 d. abc 8 what will be printed on screen, after following code is executed: string s="java is amazing"; system.out.println(s.indexof('a')+""+s.indexof('s')+"" +s.lastindexof('i')); a.1612 b.1620 c.1260 d.19 9 char variable in java has size a.1 byte b.2 bytes c.4 bytes d. it is machine dependent 10 what is the format specifier used in printf for displaying int type variables a. %c b. %s c. %d d. %b b. coding problems grade: 10 marks this part of the question paper contains two problem of 5 marks each, read them thoroughly, and write code on netbeans, run and test your code. once executed successfully, copy & paste this at space provided after the question. §§§ copy code from public static void main(string[] args) 1 write a complete java program that computes the surface area and volume of a cone. the program prompts the user to enter the radius (r) and the height (h) of the cone and then displays its surface area and volume. the program should display an error message if the height or the radius is less than or equal to zero. hint: surface area a=πr2+πrl where l= √ℎ! + ?! and volume v=1/3 πr2 h sample run 1: enter radius and height: 3 0 wrong input – height is 0 sample run 2: enter radius and height: 9 12 the area of the cone is 678.24 and its volume is 1017.36 paste your code for question 1, below: //code for question 1, starting from public static void //main(string[] args) 2. write a java program that prompts the user to enter her first, and last name as well as her psu student id. program should then make an email address for the user using her initials and the last 3 digits of her psu id. sample run: enter your first and last name: sara ahmad enter you student id: 219000123 sara ahmad, your email id is
[email protected] paste your code for question 2, below: //code for question 2, starting from public static void //main(string[] args 'd';="" c++)="" {="" system.out.print(c);="" }="" a.="" compilation="" error="" b.="" abcd="" c.="" 65666768="" d.="" abc="" 8="" what="" will="" be="" printed="" on="" screen,="" after="" following="" code="" is="" executed:="" string="" s="Java is Amazing" ;="" system.out.println(s.indexof('a')+""+s.indexof('s')+""="" +s.lastindexof('i'));="" a.1612="" b.1620="" c.1260="" d.19="" 9="" char="" variable="" in="" java="" has="" size="" a.1="" byte="" b.2="" bytes="" c.4="" bytes="" d.="" it="" is="" machine="" dependent="" 10="" what="" is="" the="" format="" specifier="" used="" in="" printf="" for="" displaying="" int="" type="" variables="" a.="" %c="" b.="" %s="" c.="" %d="" d.="" %b="" b.="" coding="" problems="" grade:="" 10="" marks="" this="" part="" of="" the="" question="" paper="" contains="" two="" problem="" of="" 5="" marks="" each,="" read="" them="" thoroughly,="" and="" write="" code="" on="" netbeans,="" run="" and="" test="" your="" code.="" once="" executed="" successfully,="" copy="" &="" paste="" this="" at="" space="" provided="" after="" the="" question.="" §§§="" copy="" code="" from="" public="" static="" void="" main(string[]="" args)="" 1="" write="" a="" complete="" java="" program="" that="" computes="" the="" surface="" area="" and="" volume="" of="" a="" cone.="" the="" program="" prompts="" the="" user="" to="" enter="" the="" radius="" (r)="" and="" the="" height="" (h)="" of="" the="" cone="" and="" then="" displays="" its="" surface="" area="" and="" volume.="" the="" program="" should="" display="" an="" error="" message="" if="" the="" height="" or="" the="" radius="" is="" less="" than="" or="" equal="" to="" zero.="" hint:="" surface="" area="" a="πr2+πrl" where="" l="√ℎ!" +="" !="" and="" volume="" v="1/3" πr2="" h="" sample="" run="" 1:="" enter="" radius="" and="" height:="" 3="" 0="" wrong="" input="" –="" height="" is="" 0="" sample="" run="" 2:="" enter="" radius="" and="" height:="" 9="" 12="" the="" area="" of="" the="" cone="" is="" 678.24="" and="" its="" volume="" is="" 1017.36="" paste="" your="" code="" for="" question="" 1,="" below:="" code="" for="" question="" 1,="" starting="" from="" public="" static="" void="" main(string[]="" args)="" 2.="" write="" a="" java="" program="" that="" prompts="" the="" user="" to="" enter="" her="" first,="" and="" last="" name="" as="" well="" as="" her="" psu="" student="" id.="" program="" should="" then="" make="" an="" email="" address="" for="" the="" user="" using="" her="" initials="" and="" the="" last="" 3="" digits="" of="" her="" psu="" id.="" sample="" run:="" enter="" your="" first="" and="" last="" name:="" sara="" ahmad="" enter="" you="" student="" id:="" 219000123="" sara="" ahmad,="" your="" email="" id="" is=""
[email protected]="" paste="" your="" code="" for="" question="" 2,="" below:="" code="" for="" question="" 2,="" starting="" from="" public="" static="" void="" main(string[]=""> 'd'; c++) { system.out.print(c); } a. compilation error b. abcd c. 65666768 d. abc 8 what will be printed on screen, after following code is executed: string s="java is amazing"; system.out.println(s.indexof('a')+""+s.indexof('s')+"" +s.lastindexof('i')); a.1612 b.1620 c.1260 d.19 9 char variable in java has size a.1 byte b.2 bytes c.4 bytes d. it is machine dependent 10 what is the format specifier used in printf for displaying int type variables a. %c b. %s c. %d d. %b b. coding problems grade: 10 marks this part of the question paper contains two problem of 5 marks each, read them thoroughly, and write code on netbeans, run and test your code. once executed successfully, copy & paste this at space provided after the question. §§§ copy code from public static void main(string[] args) 1 write a complete java program that computes the surface area and volume of a cone. the program prompts the user to enter the radius (r) and the height (h) of the cone and then displays its surface area and volume. the program should display an error message if the height or the radius is less than or equal to zero. hint: surface area a=πr2+πrl where l= √ℎ! + ?! and volume v=1/3 πr2 h sample run 1: enter radius and height: 3 0 wrong input – height is 0 sample run 2: enter radius and height: 9 12 the area of the cone is 678.24 and its volume is 1017.36 paste your code for question 1, below: //code for question 1, starting from public static void //main(string[] args) 2. write a java program that prompts the user to enter her first, and last name as well as her psu student id. program should then make an email address for the user using her initials and the last 3 digits of her psu id. sample run: enter your first and last name: sara ahmad enter you student id: 219000123 sara ahmad, your email id is sa123@psu.edu.sa paste your code for question 2, below: //code for question 2, starting from public static void //main(string[] args>