Given the following piece of code: class Student { public void talk(){} } public class Test{ public static void main(String args[]){ Student t = null; try { t.talk(); } catch(NullPointerException e){ System.out.print("There is a NullPointerException. "); } catch(Exception e){ System.out.print("There is an Exception. "); } System.out.print("Everything ran fine. "); } } what will be the result?

Answers

Answer 1

Answer:

In the output of the given piece of code, the following lines are printed on the output screen:

There is a NullPointerException. Everything ran fine.    

Explanation:

In the given code

class Student {

   public void talk(){} }

This is a Student class which has a function talk()

The following is the Test class

public class Test{

   public static void main(String args[])

   { Student t = null; try { t.talk(); }

   catch(NullPointerException e)

   { System.out.print("There is a NullPointerException. ");        

   } catch(Exception e)

   { System.out.print("There is an Exception. "); }

   System.out.print("Everything ran fine. "); } }

The above chunk of code creates a Student class object named t which is set to null. A null value is assigned to "t" to indicate that it points to nothing.

In the program a method talk() is called on a null reference. This results in NullPointerException. This is a run time exception. Since no object is created so compiler will not identify this error and this error comes in run time.

The try statement defines a code chunk that is to be tested in case of errors when the code chunk is execute. This is basically used for exception or error handling. The catch statement defines a code chunk (one or two lines of code) that executes if an error occurs in try part (block of code).

Sometimes it is needed to create a reference of the object even before creating an object and this has to be initialized or assigned a value. So null is assigned to such an object reference.

If the talk() method is intended to do something to the object t, which points to nothing, then try throws NullPointerException to indicate this error.

Since the program attempts to use an object reference that contains a null value , so when the program is executed, the try part throws NullPointerException and catch part is executed to indicate this exception. The catch part that executes contains the following statement:

   { System.out.print("There is a NullPointerException. ");

So this message is printed at output screen followed by this statement  System.out.print("Everything ran fine. "); } } message. The second catch will not execute as there is no other error in the program except for the NullPointerException. So the output is:

There is a NullPointerException. Everything ran fine.  


Related Questions

A laptop gets recycled by an e-waste recycling company once it can't be used anymore. Which stage of the hardware lifecycle does this scenario belong to

Answers

Answer:

Retirement.

Explanation:

When a laptop gets recycled by an e-waste recycling company once it can't be used anymore. This belongs to the retirement stage of the hardware lifecycle.

Hardware lifecycle can be defined as the management of the total or overall useful life of an equipment or device, so as to maximize or enhance the benefits to be derived from its use.

The retirement stage of a hardware represents the stage where the hardware has reached the end of its life-cycle and as such can not be used to perform the task for which it was designed. It is at the retirement stage, that hardwares are written off as scraps and are to be replaced by another because they can't be used anymore, as well as disposal for recycling purposes.

A={a,b,c,d} B={p,q,r,s} find the value of A-B and B-A​

Answers

Answer:

a-b=(a,b,c,d)

b-a=(p,q,r,s)

An essential skill today is knowing how to cite sources properly. Creative Commons has a system of licenses and tools for creators to retain copyright while allowing others to:

Answers

Answer:

Copy, distribute, and remix

Explanation:

Creative Commons is not for profit international network and organisation with head quarters in America that enables the discovery of material that are openly licensed so as to be available for use by others fostering the possibility to gain educational insight to creative works to serve as foundation for their own works legally. Creative Commons provide CC licences that are accessed by content creators with a desire to share their creativity on the web.

give brainliest if you tell me the can tell me the most random thing

Answers

Mood

Explanation:

Because it gets changed by the time you are happy or sad. Same that while you are reading if you like your. mood gets good but if you dont find this ans satisfied your mood gets changed.

A computer retail store has 15 personal computers in stock. A buyer wants to purchase 3 of them. Unknown to either the retail store or the buyer, 3 of the computers in stock have defective hard drives. Assume that the computers are selected at random.
(a) In how many different ways can the 4 computers be chosen?
(b) What is the probability that exactly one of the computers will be defective?
(c) What is the probability that at least one of the computers selected is defective?

Answers

Answer:

a. 1365 ways

b. Probability = 0.4096

c. Probability = 0.5904

Explanation:

Given

PCs = 15

Purchase = 3

Solving (a): Ways to select 4 computers out of 15, we make use of Combination formula as follows;

[tex]^nC_r = \frac{n!}{(n-r)!r!}[/tex]

Where [tex]n = 15\ and\ r = 4[/tex]

[tex]^{15}C_4 = \frac{15!}{(15-4)!4!}[/tex]

[tex]^{15}C_4 = \frac{15!}{11!4!}[/tex]

[tex]^{15}C_4 = \frac{15 * 14 * 13 * 12 * 11!}{11! * 4 * 3 * 2 * 1}[/tex]

[tex]^{15}C_4 = \frac{15 * 14 * 13 * 12}{4 * 3 * 2 * 1}[/tex]

[tex]^{15}C_4 = \frac{32760}{24}[/tex]

[tex]^{15}C_4 = 1365[/tex]

Hence, there are 1365 ways

Solving (b): The probability that exactly 1 will be defective (from the selected 4)

First, we calculate the probability of a PC being defective (p) and probability of a PC not being defective (q)

From the given parameters; 3 out of 15 is detective;

So;

[tex]p = 3/15[/tex]

[tex]p = 0.2[/tex]

[tex]q = 1 - p[/tex]

[tex]q = 1 - 0.2[/tex]

[tex]q = 0.8[/tex]

Solving further using binomial;

[tex](p + q)^n = p^n + ^nC_1p^{n-1}q + ^nC_2p^{n-2}q^2 + .....+q^n[/tex]

Where n = 4

For the probability that exactly 1 out of 4 will be defective, we make use of

[tex]Probability = ^nC_3pq^3[/tex]

Substitute 4 for n, 0.2 for p and 0.8 for q

[tex]Probability = ^4C_3 * 0.2 * 0.8^3[/tex]

[tex]Probability = \frac{4!}{3!1!} * 0.2 * 0.8^3[/tex]

[tex]Probability = 4 * 0.2 * 0.8^3[/tex]

[tex]Probability = 0.4096[/tex]

Solving (c): Probability that at least one is defective;

In probability, opposite probability sums to 1;

Hence;

Probability that at least one is defective + Probability that at none is defective = 1

Probability that none is defective is calculated as thus;

[tex]Probability = q^n[/tex]

Substitute 4 for n and 0.8 for q

[tex]Probability = 0.8^4[/tex]

[tex]Probability = 0.4096[/tex]

Substitute 0.4096 for Probability that at none is defective

Probability that at least one is defective + 0.4096= 1

Collect Like Terms

Probability = 1 - 0.4096

Probability = 0.5904

technician is dispatched to troubleshoot a user's computer. After performing diagnostics, the technician determines that drive thrashing is occurring. What are the factors that can affect this?

Answers

Answer:

Factors that can affect drive thrashing are;

The computer memory modules

Hard drives

Running processes

Paging file  

Explanation:

Drive thrashing also known as disk thrashing occurs due to over stressing the hard drives by moving data from the from virtual memory,(paging file) to system memory,(RAM) and back again such that the memory becomes exhausted resulting in slow performance or system halting.

Factors that can affect drive thrashing are the computer memory modules, hard drives, running processes, and paging file  

When thrashing occurs, the computer performance is slowed down or halts as the hard drives resources has reached close to capacity.

A _______ is conducted to determine the adequacy of system controls, ensure compliance with established security policy and procedures, detect breaches in security services, and recommend any changes that are indicated for countermeasures.

Answers

Answer:

security audit

Explanation:

MS Excel is a powerful spreadsheet program that helps people with complex mathematical calculations. In what ways could you use Excel for personal, work and school purposes? Give an example for all three.

Answers

Answer:

Explanation:

En Google te sale la respuesta fácilmente.

Solo pones la pregunta primero con personales, luego con laborales y así...

Y de luego los ejemplos

Once you have a listing of every unique combination of salesperson, product and location, what Excel function would you use to compute the total sales for each combination of salesperson, product and location

Answers

Answer:

SUMIFS

Explanation:

As we know that the excel is used to present the data in a very attractive way by applying the formulas, pie charts, functions as a pivot table, goal seeking, macros, etc

In order to determine the total sales for each and every sales person, production and location combination we use the SUMIFS function so that the total of each column could come in an easiest and better way

Which of these jobs would be most appropriate for someone who majors in information technology? managing a database for a large department store developing new computing technology that will someday improve network speeds managing the computer network for a large department store designing the hardware for a military helicopter's on-board computer

Answers

Answer:

A

Explanation:

managing the computer network for a large department store

The job that would be most appropriate for someone who majors in information technology is to manage the computer network for a large department store. Thus, the correct option for this question is C.

What is Information technology?

Information technology may be defined as a broad study of a system and network that uses the computer's hardware, software, services, and supporting infrastructure in order to manage and deliver information using voice, data, and video.

So, the job associated with information technology may require the significant utilization of computers and networks over a huge range of numbers. Managing a database is the work of software engineers, designing the hardware for a military helicopter's onboard computer is the work of hardware engineers, etc.

Therefore, the job that would be most appropriate for someone who majors in information technology is to manage the computer network for a large department store. Thus, the correct option for this question is C.

To learn more about Information technology, refer to the link:

https://brainly.com/question/4903788

#SPJ5

Which among the following is a fraudulent or deceptive act designed to trick individuals into spending time or money for little or no return?
A. Internet scams
B. Data manipulation
C. Theft
D. Malicious programs

Answers

Answer:

A. Internet scams.

Explanation:

Internet scams is a fraudulent or deceptive act designed to trick individuals into spending time or money for little or no return through the use of a cloud service or the internet. Some examples of an internet scam are phishing scams, email spams, credit card scam, etc. It is simply centred around the provision of false information or misrepresentation of another party for the sole purpose of theft.

Hence, an internet scam is an illegal means of obtaining things from people and such is a cyber crime that is punishable by law.

After performing several upgrades on a computer, the user reports that he is having trouble with an overheating problem. You want to make recommendations to help prevent the computer from overheating during use. What should you recommend?

Answers

Complete Question:

After performing several upgrades on a computer, the user reports that he is having trouble with an overheating problem. You want to make recommendations to help prevent the computer from overheating during use. What should you recommend?

Group of answer choices

A. Apply a higher voltage to the cooling fans.

B. Use an installed video card rather than a built-in video chip on the system board.

C. Use a blank-screen screen saver.

D. Keep the computer cover closed and secured.

Answer:

D. Keep the computer cover closed and secured.

Explanation:

Assuming that after performing several upgrades on a computer, the user reports that he is having trouble with an overheating problem. The recommendation to help prevent the computer from overheating during use is to keep the computer cover (tower case) closed and secured.

All computer covers (tower cases) have an opened designed by the manufacturer which allows uniform dissipation of heat through the use of an airflow cooling system. Hence, it is very important that the computer cover is closed and secured in order to maintain an effective and efficient cooling system.

Additionally, you should ensure the cooling fan or case fan is working properly and a heat sink is installed.

A(n) __________ item is a hardware or software item that is to be modified and revised throughout its life cycle.

Answers

Answer: configuration

Explanation: hardware also known as a software.

Answer: configuration

Explanation: hardware also known as a software.  

helping is caring :)

Think about some of the most memorable and forgettable games ever created. They can be games that were
discussed in this unit or otherwise. What are some of the consistent factors that made certain games
memorable to you? What were some of the consistent factors that made certain games forgettable to you?
Why? Explain.

Answers

Answer:

There can be many reasons.

Explanation:

1) Unforgettable story

2) The scenery is soooo good (for example, Legends of Zelda : Breath of the Wild)

3) The meaning behind the game.

4) Why the game was created caught your attention

Hope I helped!

A Transmission Control Protocol (TCP) connection is established and two devices ensure that they're speaking the same protocol. What has occured?
A. Three-way handshake
B. Two-way handshake
C. Handshake
D. Four-way handshake

Answers

Answer:

The correct option is;

A. Three-way handshake

Explanation:

For establishment of connection within Transmission Control Protocol, (T. C. P.), involves a three-way way handshake. Prior to attempting a server connection, the server to which connection is sought passively opens a port by listening at the port. Upon establishment of passive open, active open by the client can then be initiated by the client. A connection establishment requires a three-way handshake as follows;

1. The client sends a SYN to the server

2. The server responds by sending a SYN-ACK

3. The client further responds sending ACK back to the server.

Choose the wrong statement. Proper pagination is required for the overall good performance of a domain in search results Pagination is extremely important in e-commerce and editorial websites It is important to have all sub-pages of a category being indexed rel=next and rel=prev attributes explain to Google which page in the chain comes next or appeared before it

Answers

Answer:

The wrong statement in this question is "It's important to have all sub-pages of a category being indexed".

Explanation:

In the given-question, the above choice is incorrect because  all subpages in such a segment are not important to also be indexed, and the other correct choice can be defined as follows:

For both the total good performance of even an area in search engine results, acceptable pagination is required.  rel = next and prev, values are an attribute, that describes its page throughout the chain next to it and originally shown by Google.  Throughout e-commerce as well as publishing internet sites, scrollbars are extremely important.  

qbasic write a program to input number of keyboard to purchase and display the total amount to be paid for with dry run and output step by step​

Answers

Answer:

DIM cost, amount

cost=8

INPUT "How many do you want to purchase";amount

PRINT "Total cost: ";amount*cost

Explanation:

What do you mean by dry run?

List some good names for devices on your home network or on the network in your school's lab. Demonstrate the use of best practices when creating a naming scheme for devices on a computer network.

Answers

Answer:

Following are the answer to this question:

Explanation:

The following is the list of name devices, which is used home network or the school lab.

hrtr01(home router 1). schadmrtr02(school building router 2). clpc01, and clpc02 (computer laboratory pc 1 and 2) .

Uses:

Its use as descriptive names as necessary without gives potential hacks much more relevant data.  It provides only areas that are essential for both device identification.  It allows the name for irrelevant or redundant information doesn't over-complicated.

Robert complains that the cursor on his laptop screen often jumps around unexpectedly when he’s typing. What can he do to solve the problem?

Answers

Answer:

Disable the touchpad

Explanation:

my I phone is in recovery mode and when I connect to my PC the I device is not connected to iTunes although i have the latest version of iTunes. and the device is also unspecified in the devices. How to fix this problem?

Answers

Answer:

Your best bet is to put ur phone in recovery mode again and use ur computer to reset it.

If all else fails contact your phone company.

Explanation:

put your phone on recovery mode and connect to your computer or you go to where they can fix the phone

Word processing is the use of computer software to enter and edit text.

Answers

Answer:

True

Explanation:

Word processing software or word processing program handles functions related to entering and editing text in a text document. In essence a word processor processes text documents which includes processing entire papers, paragraphs, pages. With a word processing software text is entered  in the document mainly through typing in the letters with a keyboard and a word processor allows copying, deleting and formatting text through the use of built in commands

Examples of word processing programs are Microsoft Word, AppleWorks and OpenOffice.

Vivian wants to increase the storage capacity of her computer. Which components should she upgrade?

Answers

Answer:

Hard drive

Explanation:

The hard drive is where the operating system, programs and data reside on (unless the data is saved and backed up elsewhere). An older hard drive that uses platters for reading and writing data to it will be slower than a later model solid state device. Newer hard drives have very fast access speeds compared to older units.

Answer:

I'm pretty sure it's Hard Drive and RAM

Explanation:

What is a command-line interactive scripting environment that provides the commands for almost any management task in a Windows Server 2016 environment?

Answers

Answer:

kqwbxskwsxe

Explanation:

menb dhj

Distinguish between the savings and investment options.
Savings
Investments
mutual hd
money market
gold
certificate of deposit
account​

Answers

Answer:

Savings,                          Investments

[tex]{}[/tex]Certificate of deposit    Mutual fund

[tex]{}[/tex]Account                         Money Market

[tex]{}[/tex]                                        Gold

Explanation:

Savings is the term used to describe the proportion of ones income not spent or kept for spending at a much later date;

Saving methods includes saving money in deposit accounts, pension savings, and cash savings as well as reducing expenditures

Savings differs from investment in the sense that investments involves more risks than savings

Mutual fund

Mutual fund is a financial resource type involving the bringing together of funds gathered from several investors for investment

Money market

The money market involves buying and selling debt investments that are short terms

Gold

Gold investment is a way of diversifying risk through futures and derivatives and futures contracts

Certificate Deposit

Certificate deposit is a fixed term deposit form of savings that provides an interest on the deposit

Account

Savings and current account are meant for saving funds

what is an email account​

Answers

Answer:

an email account acts as a virtual address for email messages

email account is where you can send messages someone is a formal way through a laptop phone ipad basically any type of devices but it’s most professional to send from a laptop

Define a public static method named s2f that takes two String arguments, the name of a file and some text. The method creates the file and writes the text to it. If all goes well the method returns true. If, however, either of its arguments are null or if there is any problem in creating or writin

Answers

Answer:

Java solution (because only major programming language that has public static methods)

(import java.io.* before hand)

public static boolean s2f(String fileName, String text){

   try{

       PrintWriter out = new PrintWriter(new File(fileName));

       out.println(text);

       out.close();

       return true;

   }

   catch(Exception e){

       return false;

   }

}


The house had a wonderful pool of ... (his/its/our) own.​

Answers

Answer:

its

Explanation:

"It" used in a number of different forms of sentences and has several rules. 'It' can be used in a sentence either for a Subject or an Object. It can be used as an introductory word in a sentence when there is no mention of the subject. It used for the singular, third-person pronoun. While it has many uses and according to the question, it is used to refer to a lifeless object (home).

If you were doing a regular expression inside a Linux command line, which special character on the keyboard would give you two possible matches using the example below: car ____ truck

Answers

Answer: car | truck

Explanation: The pipe (|) symbol used can be used in regular expression to simply imply OR. This means when used in between expression, can be used to search for all matches of the strings in which it stands in between. In the scenario above, If the pipe symbol is located in between the two strings, such as [ cars | trucks], the expression returns possible occurrence of the strings cars and trucks. It may also be used to locate and return the occurrences of more than 2 strings, such as; string1 | string2 | string3

Productivity software has been used for a number of years. Recent advancements in productivity software technology have made _____ among multiple users all over the world a possibility.

Answers

Answer:

The best and most correct answer among the choices provided by the question is the second choice.

Explanation:

Recent advancements in productivity software technology have made e-mailing among multiple users all over the world. I hope my answer has come to your help. God bless and have a nice day ahead!

how do you think someone has programmed computer calculator?​

Answers

Answer:

Originally, calculator programming had to be done in the calculator's own command The most basic calculations are addition, subtraction, multiplication, and division. The more transistors an integrated circuit has, the more advanced mathematical functions it can perform.

Other Questions
Find the area of the polygon with the given vertices. J(-3,4), K(4,4), L(3,-3) Write a ratio for the following description: For every 6 cups of flour in a bread recipe, there are 2 cups of milk. Type your answer in the format: 3:4 with no spaces. Describe a situation that could be modeled with the ratio 4: 1. Help please, 1-8n-8= -7n-6n-12? my I phone is in recovery mode and when I connect to my PC the I device is not connected to iTunes although i have the latest version of iTunes. and the device is also unspecified in the devices. How to fix this problem? part 7: please assist me with these problems CA-Algebra 1 (S1 20-21)Creating a Situation for a GraphJanelle's Trip HomeBased on the graph, which statement could describeJanelle's trip home from school?O Janelle waited for the bus, rode the bus, and thenwalked homeDistance from Home (mi)O Janelle walked the opposite direction from home tothe library, rode the bus, and then walked to afriend's house.O Janelle walked home at a constant speed.O Janelle rode the bus to the bus stop, talked with afriend, and then walked home.Time (min)US 17:28ivityAnswer: She rode the bus to the bus stop talked with a friend and then walked home. Whats the ratio for this rectangle f(x) = x/2 - 1 find f (12) Match the Pronoun with the correct form of the verb tener.Column AColumn B1.Yoa. tengo2.Tb. tenis3.I, Ella, Ud.C. tienes4.Nosotros(as)d. tienen5.Vosotros(as)e. tenemos6.Ellos, Ellas, Uds.f. tiene who started world war I? A company had revenues of $54,000 and expenses of $43,250 for the accounting period. The company paid $5,950 cash in dividends to the owner (sole shareholder). Which of the following entries could not be a closing entry?A. Debit Income Summary $10,750; credit Retained Earnings $10,750.B. Debit Income Summary $54,000; credit Revenues $54,000.C. Debit Revenues $54,000; credit Income Summary $54,000.D. Debit Income Summary $43,250, credit Expenses $43,250.E. Debit Retained Earnings $5,950, credit Dividends $5,950. The following data relate to labor cost for production of 22,000 cellular telephones: Actual: 4,220 hrs. at $44.50 Standard: 4,160 hrs. at $46.00Required:Determine the direct labor rate variance, direct labor time variance, and total direct labor cost variance. Use complete sentences to discuss three things, besides those presented in the lesson, that it is important for others to know about Millennials or Generation Y, the group born from 1981 to 2001. In your response, it is important to think about the group as a whole rather than thinking of a specific individual. guys I am in 8th grade and the question is your cultural background can affect your health. TRUE OR FALSE At the end of the day of teaching the skill of cutting and sewing to make capes, Ms. Ironperson and Mr. Thoro decided to go to the Shawarma Mediterranean Grill. Ms. Ironperson ordered 3 chicken shawarma wraps and 2 orders of spiced potatoes for a total bill of $42.95. Mr. Thoro ordered 5 chicken shawarma wraps and 4 orders of spiced potatoes for a total bill of $74.91. What is the cost of a chicken shawarma wrap? What is the cost of one order of spiced potatoes? The lengths of a certain species of fish were found to be normally distributed. The mean length is 73 cm with a standard deviation of 8 cm. In a school of 480 of these fish, about how many would be longer than 57 cm? Select the correct answer.When you step on a bathroom scale, it tells you how much you weigh. How is the word weight defined? If you're not sure,take a guess.the amount of matter in an objecta measure of the pull of gravity on an objectthe speed at which an object strikes Earththe distance between an object and Earth Maria and Ming start at the same point and drive in opposite directions. Maria drives 48 mph and Ming drives 50 mph. How far apart will they be in 2 hours? The Persian empire maintained order through a policy of terror and oppression. belief in one god. use of missionaries and public edicts. tolerance and good government. "A customer who earns $80,000 per year is 35 years old, married to a non-working spouse, has a 5-year-old child, has no retirement savings and does not have a will. This customer receives $250,000 in a single stock as an inheritance from her deceased aunt. What is the first thing that the customer should do?"