Java Programming, Loose-leaf Version
8th Edition
ISBN: 9781337685917
Author: Joyce Farrell
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 12, Problem 9RQ
Program Description Answer
Any number of statements can be placed within a try block.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Please answer properly with output screenshot must
Where is the error in this code?
from telethon.sync import TelegramClientfrom telethon.tl.functions.messages import GetDialogsRequestfrom telethon.tl.types import InputPeerEmptyimport os, sysimport configparserimport csvimport time
re="\033[1;31m"gr="\033[1;32m"cy="\033[1;36m"
def banner():os.system('clear')print("ok")
cpass = configparser.RawConfigParser()cpass.read('config.data')
try: api_id = cpass['cred']['id'] api_hash = cpass['cred']['hash'] phone = cpass['cred']['phone'] client = TelegramClient(phone, api_id, api_hash)except KeyError: os.system('clear') banner() print(re+"[!] run python3 setup.py first !!\n") sys.exit(1)
client.connect()if not client.is_user_authorized(): client.send_code_request(phone) os.system('clear') banner() client.sign_in(phone, input(gr+'[+] Enter the code: '+re))os.system('clear')banner()chats = []last_date = Nonechunk_size = 200groups=[]result =…
Assuming all values are initially zero, what are the values of A and B aft er executing this Verilog code inside an always block?C=1;A <= C;B = C;
lst = [10, 20, 30, 40, 50, 60, 70, 80] def f(lst, seek):
for i in range(len(lst)): if lst[i] == seek:
return i # Return position immediately return None
f(lst,50)
What is the output of this code part?
A)3 B)4 C)5 D)none
Chapter 12 Solutions
Java Programming, Loose-leaf Version
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Q1) The following snippet of code inputs an integer and outputs it:int num=0;Scanner kbd = new Scanner(System.in);num = kbd.nextInt();System.out.println(num);Run this program but enter text instead of an integer. The programshould crash and tell you what kind of exception was thrown by thenextInt method. Wrap this code inside a try/catch block where youcatch the exception that is thrown. Add a loop so the user must enterthe number again if text is entered.Q2) The following class maintains an account balance and returns a special error code.public class Account{private double balance;// returns new balance or -1 if errorpublic double deposit(double amount){if (amount > 0)balance += amount;elsereturn -1; // Code indicating errorreturn balance;}}Rewrite the class so that it throws appropriate exception instead ofreturning -1 as an error code. Write test code that attempts to deposit invalid amounts and catches the exceptions that are thrownarrow_forwardTo use dynamic memory allocation functions, which of the following header files must be included?a) stdlib.hb) stdio.hc) memory.hd) dos.harrow_forwardINCLUDE Irvine32.inc .dataprompt1 BYTE "Enter the first number: ",0prompt2 BYTE "Enter the second number: ",0num1 DWORD ?num2 DWORD ?answer DWORD ?answer1 BYTE " - ",0answer2 BYTE " = ", 0 .codemain PROCMOV EDX, OFFSET prompt1 ;Prompt for the first numberCALL WriteStringCALL ReadDecMOV num1, EAX MOV EDX, OFFSET prompt2 ;Prompt for the second numberCALL WriteStringCALL ReadDecMOV num2, EAX SUB EAX, num1 ;Calculate num2 – num1MOV answer, EAX MOV EAX, num2 ;Print the answerCALL WriteIntMOV EDX, OFFSET answer1CALL WriteStringMOV EAX, num1CALL WriteIntMOV EDX, OFFSET answer2CALL WriteStringMOV EAX, answerCALL WriteIntCALL CRLFEXITmain ENDPend mainarrow_forward
- Create an anonymous block that a teacher can run to insert the student's grade on a particular assignment. Accept a NUMERIC_GRADE, CLASS_ASSESSMENT_ID, CLASS_ID and STU_ID. Use “today‟s” date for the DATE_TURNED_IN.arrow_forwardQuestion (1): Write a program that asks the user to enter an integer greater than zero and store it in a variable called “n”. Then it calculates the final value that will be stored in a variable called “s” according to the following equation And add an exception when the user enters any value other than integer shows the message “You entered non integer value, please try again.”, and let the user to enter a new value.Example 1Enter an integer: 4S = -2.0Example 2Enter an integer: aYou entered non integer value, please try again.Enter an integer: 4S = -2.0arrow_forwardPlease identify the correct statement(s) for the following code snippet from the script: while inst_iter.hasNext() and not monitor.isCancelled(): ins = inst_iter.next() addr = ins.getAddress() pcodeList = ins.getPcode() for pcode in pcodeList: if pcode.getOpcode() == PcodeOp.FLOAT_DIV or pcode.getOpcode() == PcodeOp.INT_DIV: print("Address: {}, Inst: {}, Pcode: {}".format(addr, ins, pcode)) addrSet.add(addr) Question 1 options: It saves the address of the disassembled instruction that introduces division. This snippet uses refined/high p-code. This snippet uses raw p-code. It uses p-code opcode to identify the division operator. It uses the mnemonic string of a disassembled instruction to identify the division operator. It saves the sequence number of the p-code instruction that introduces division.arrow_forward
- Shell script environmental variable Here are two programs called prog1 and prog2: $ cat prog1 e1=100 export e1 e2=200 e3=300 prog2 $ cat prog2 echo “e1=$e1 e2=$e2 e3=$e3 e4=$e4” A. Create the above programs in your CS server Linux account. B. What output do you get after typing the following? (List and explain the output after each execution of prog1.) $ prog1 $ export e2=20 $ prog1 $ export e3=30 $ prog1 export e4=40 $ prog1arrow_forward#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main(){ int stdout_bak = dup(STDOUT_FILENO); // make a backup of stdout system("rm -f mystery.txt"); // remove file using a shell command int out_fd = open("mystery.txt", // open file mystery.txt O_WRONLY|O_CREAT, // for writing, create if needed S_IRUSR|S_IWUSR); // give user read/write permission if(out_fd == -1){ // check for errors opening file perror("Couldn't open file 'mystery.txt'"); exit(1); // bail out if open fails } printf("1. Now you see me.\n"); // print to the screen dup2(out_fd, STDOUT_FILENO); // change stdout to go to mystery.txt printf("2. Now you don't!\n"); // print goes to mystery.txt close(out_fd); // close mystery.txt dup2(stdout_bak, STDOUT_FILENO); // restore stdout to screen…arrow_forwardWhen running this script : # Split input into 2 parts: name and age parts = input().split() name = parts[0] while name != '-1': # FIXME: The following line will throw ValueError exception. # Insert try/except blocks to catch the exception. try: # the try block increments the age by 1 of all inputs whose second index is an integer age = int(parts[1]) + 1 print('{} {}'.format(name, age)) # Get next line parts = input().split() name = parts[0] except ValueError: # the except block checks to see if the second index in the user input is an integer and if not age = 0 # the value of the second index is changed to 0 print('{} {}'.format(name, age)) # Get next line parts = input().split() name = parts[0] i get any error when i input Mary Beth 19, How can i fix my code to handle this?arrow_forward
- Question and compiler output with error is provided in the attachment. And my solution is provided below. kindly correct my code and make it error-free also match output. -----MY SOLUTION----- MAIN.CPP #include<iostream>#include<string>#include<stdio.h>#include<fstream>#include<list>#include<iterator>#include<sstream>#include"UserBO.cpp"using namespace std;int main(){int num;cout<<"Enter the number of users:";cin>>num;string name;string contact;string uname;string password;User U[10];for(int i = 0; i < num; i++){cout<<endl<<"Enter the name of user :";cin>>name;cout<<endl<<"Enter the contact number :";cin>>contact;cout<<endl<<"Enter the username :";cin>>uname;cout<<endl<<"Enter the password :";cin>>password;User k(name, uname, password, contact);U[i] = k;}ofstream file;file.open("example.txt",ios::out);UserBO ub;ub.writeUserdetails(file, U, num);return…arrow_forward17. Which statement is true about what will happen when the example code runs?1: main PROC2: mov eax,303: push eax4: push 405: call Ex3Sub6: INVOKE ExitProcess,07: main ENDP8:9: Ex3Sub PROC10: pusha11: mov eax,8012: popa 3: ret14: Ex3Sub ENDPa. EAX will equal 40 on line 6b. The program will halt with a runtime error on Line 6c. EAX will equal 30 on line 6d. The program will halt with a runtime error on Line 13arrow_forwardCostumers do online shopping using ATM cards. The card number contains 16 digits having 4 parts with equal parts, example "XXX YYYY ZZZZ Wwww". This number should not start or end with zero. XXXX will divisible by 7, the sum of digits in YYYY will be a prime number, ZZZZ will not be a palindrome number. The first digit of ZZZZ should be an even number. Write a program to raise exception if these conditions are not satisfied.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License