Free Essay

Tech

In: Computers and Technology

Submitted By clintonmaushe
Words 1059
Pages 5
JAVA - INTERFACES http://www.tuto rialspo int.co m/java/java_inte rface s.htm
Co pyrig ht © tuto rials po int.co m

An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. An interface is not a class. Writing an interface is similar to writing a class, but they are two different concepts. A class describes the attributes and behaviors of an object. An interface contains behaviors that a class implements. Unless the class that implements the interface is abstract, all the methods of the interface need to be defined in the class. An interface is similar to a class in the following ways: An interface can contain any number of methods. An interface is written in a file with a .java extension, with the name of the interface matching the name of the file. T he bytecode of an interface appears in a .c lass file. Interfaces appear in packag es, and their corresponding bytecode file must be in a directory structure that matches the packag e name. However, an interface is different from a class in several ways, including : You cannot instantiate an interface. An interface does not contain any constructors. All of the methods in an interface are abstract. An interface cannot contain instance fields. T he only fields that can appear in an interface must be declared both static and final. An interface is not extended by a class; it is implemented by a class. An interface can extend multiple interfaces.

Declaring Interfaces:
T he interfac e keyword is used to declare an interface. Here is a simple example to declare an interface:

Example:
Let us look at an example that depicts encapsulation:
/* File name : NameOfInterface.java */ import java.lang.*; //Any number of import statements public interface NameOfInterface { //Any number of final, static fields //Any number of abstract method declarations\ }

Interfaces have the following properties: An interface is implicitly abstract. You do not need to use the abstrac t keyword when declaring an interface. Each method in an interface is also implicitly abstract, so the abstract keyword is not needed.

Methods in an interface are implicitly public.

Example:
/* File name : Animal.java */ interface Animal { public void eat(); public void travel(); }

Implementing Interfaces:
When a class implements an interface, you can think of the class as sig ning a contract, ag reeing to perform the specific behaviors of the interface. If a class does not perform all the behaviors of the interface, the class must declare itself as abstract. A class uses the implements keyword to implement an interface. T he implements keyword appears in the class declaration following the extends portion of the declaration.
/* File name : MammalInt.java */ public class MammalInt implements Animal{ public void eat(){ System.out.println("Mammal eats"); } public void travel(){ System.out.println("Mammal travels"); } public int noOfLegs(){ return 0; } public static void main(String args[]){ MammalInt m = new MammalInt(); m.eat(); m.travel(); } }

T his would produce the following result:
Mammal eats Mammal travels

When overriding methods defined in interfaces there are several rules to be followed: Checked exceptions should not be declared on implementation methods other than the ones declared by the interface method or subclasses of those declared by the interface method. T he sig nature of the interface method and the same return type or subtype should be maintained when overriding the methods. An implementation class itself can be abstract and if so interface methods need not be implemented. When implementation interfaces there are several rules: A class can implement more than one interface at a time. A class can extend only one class, but implement many interfaces. An interface can extend another interface, similarly to the way that a class can extend another class.

Extending Interfaces:

An interface can extend another interface, similarly to the way that a class can extend another class. T he extends keyword is used to extend an interface, and the child interface inherits the methods of the parent interface. T he following Sports interface is extended by Hockey and Football interfaces.
//Filename: Sports.java public interface Sports { public void setHomeTeam(String name); public void setVisitingTeam(String name); } //Filename: Football.java public interface Football extends Sports { public void homeTeamScored(int points); public void visitingTeamScored(int points); public void endOfQuarter(int quarter); } //Filename: Hockey.java public interface Hockey extends Sports { public void homeGoalScored(); public void visitingGoalScored(); public void endOfPeriod(int period); public void overtimePeriod(int ot); }

T he Hockey interface has four methods, but it inherits two from Sports; thus, a class that implements Hockey needs to implement all six methods. Similarly, a class that implements Football needs to define the three methods from Football and the two methods from Sports.

Extending Multiple Interfaces:
A Java class can only extend one parent class. Multiple inheritance is not allowed. Interfaces are not classes, however, and an interface can extend more than one parent interface. T he extends keyword is used once, and the parent interfaces are declared in a comma-separated list. For example, if the Hockey interface extended both Sports and Event, it would be declared as: public interface Hockey extends Sports, Event

Tag g ing Interfaces:
T he most common use of extending interfaces occurs when the parent interface does not contain any methods. For example, the MouseListener interface in the java.awt.event packag e extended java.util.EventListener, which is defined as: package java.util; public interface EventListener {}

An interface with no methods in it is referred to as a tag g ing interface. T here are two basic desig n purposes of tag g ing interfaces: Creates a c ommon parent: As with the EventListener interface, which is extended by dozens of other interfaces in the Java API, you can use a tag g ing interface to create a common parent among a g roup of interfaces. For example, when an interface extends EventListener, the JVM knows that this particular interface is g oing to be used in an event deleg ation scenario. Adds a data type to a c lass: T his situation is where the term tag g ing comes from. A class that implements a tag g ing interface does not need to define any methods (since the interface does not have any), but the class becomes an interface type throug h polymorphism.

Similar Documents

Free Essay

Innovation

...CHINA BOOST FOR SENAI HI-TECH PARK Senai Hi-Tech Park, Malaysia's second high technology industrial park, got off to a promising start with investments of more than US$500 million (RM1.7 billion) from two companies in Johor. China-based EQ Solar Technology International Sdn Bhd plans to invest US$500 million to produce solar modules while leading industrial gases provider MOX-Linde Gases Sdn Bhd, through its initial outlay of RM60 million, plans to set up an industrial gases separation plant. Senai High Tech Park chief executive officer (CEO) Datuk Ahmad Shukri Tajudin said this shows that the park is ready to compete as another preferred location for hightechnology manufacturing, research and innovation activities. Located within Iskandar Malaysia, the park has drawn interest from investors in the US, Europe and China. "Interest is in various sectors including semiconductor industry and solar," he said at a media briefing. International Trade and Industry Minister Datuk Seri Mustapa Mohamed, witnessed the signing of the memorandum of understanding in Kuala Lumpur yesterday. "We're expecting a few more similar investments," Mustapa said, without disclosing details. Malaysia has so far attracted several global solar industry players like First Solar, Sunpower and Q-Cells. There are also several domestic investments in solar power projects in Selangor and Sabah. Mustapa hopes that the park will create more jobs, similar to what was achieved at the Kulim Hi-Tech Park in the......

Words: 452 - Pages: 2

Free Essay

Guillermo Furniture

...over the years. Guillermo Furniture Store Recommendation Analysis and Recommend Financial Decision The economy is weak, new competitors’ establishing a presents, Guillermo must tackle a tough decision, which is to become a furniture distributor or stay on the manufacturing side, or possibility do both. Guillermo understands that change is forth coming and he has to venture forward but the dilemma is what the best alternative is. First Guillermo must analysis the financial alternatives and establish which objective is beneficial for the company. The next step is to gather information and formulate a pro forma cash flow budget to analyze the projected earnings for the next five years for the company (University of Phoenix, 2007). Hi-Tech Option Guillermo established his wealth various years ago because of the low cost in labor along with an extraordinary location for manufacturing. The company’s success has held strong on those foundations until now. There are a few concerns for Guillermo that may cause the company to change the way it does...

Words: 2497 - Pages: 10

Premium Essay

Hrm in Israel

...The transition from a Socialist approach to a free market approach and the rise of a new high-tech sector are two remarkable shifts that have occurred in the last two decades in Israel. In the face of these changes, human resource (HR) practitioners are currently expected to assume new roles, adopt different work values, and apply appropriate strategies. HR managers in the low-tech industry still adhere to traditional values and strategies, including a reliance on trade unions and an emphasis on job security and the employees’ years of work experience and seniority as key criteria for promotion. In the emerging high-tech sector, HR managers have adopted new values and developed new strategies, including human resource management programs, employee empowerment, higher salaries and better benefits, while placing an emphasis on employees’ talents and qualifications. Source: http://www.emeraldinsight.com/journals.htm/journals.htm?issn=01437720&volume=22&issue=3&articleid=848302&show=html&PHPSESSID=qj5kp1babsuadbfaj 47luam41 Recent changes in Israeli society and economy and their relation to Organizational Politics Over the past three decades, Israel has undergone significant economic, industrial and cultural transformations. These developments have shifted public values considerably and may indirectly affect OP and HR practices. For example, Sagie and Weisberg (2001) maintain that in recent years, Israeli society has gone from being......

Words: 1651 - Pages: 7

Premium Essay

Four Strategically Required Organizational Outcomes for Siemens

...strategy-oriented HR system case study 1. * Strategically required organizational outcomes: * Good products and good services. Products and services is always the most important thing for a manufacturing company. Siemens has become a world leader by diversifying into hi-tech products and services, it need to maintain this advantage and develop it even further to achieve more. * Going global and expand. Globalization gives big companies a chance to expand rapidly. Siemens has succeeded in going global but this is a long way, it still needs more expansion into more countries or areas that are not covered yet. * Positive brand image. A good company image is extraordinarily important to the company’s healthy development. Siemens needs to keep customers satisfied both with its products and services, which helps it to get more market share and expand even faster. * A good employee selection, training and compensation system. The company not just need to keep customers satisfied, it has to keep employees happy too. So that it can work more efficiently and effectively. * Required workforce competencies and behaviors: * Learning on a continuing basis. Siemens is in high-tech business so the nature decided that its employees need to learn new things every day. * Good teamwork. The ability to work with people is essential in such big corporation. Especially when it’s going global. * Mutual respect and appreciation of workforce diversity.......

Words: 296 - Pages: 2

Free Essay

Tech

...new TLF Panel survey conducted on behalf of kids clothing retailer Vertbaudet.co.uk found that four in five parents believe technology and gadgets are good for kids, aiding in their development. The study found that 37 percent of parents asked said that their child spent between one and two hours a day playing with tech gadgets, and 28 percent said between two- and three hours. Moreover, the study found that 38 percent of two- to five-year-olds own an Android tablet, and 32 percent own an iPad; almost a third (32 percent) of these kids also have a mobile phone. The reason behind all this gadget use: over a third of parents (35 percent) said they use tech gadgets to entertain their children because they are convenient, and nearly a quarter (23 percent) because they want their children to be tech-savvy. A 2015 survey of 1,000 British mothers of children aged 2 to 12 found that 85 percent of mums admit to using technology to keep the kids occupied while they get on with other activities. The AO.com survey pointed to children spending on average around 17 hours a week in front of a screen – almost double the 8.8 weekly hours spent playing outside. Wanting our children to tech-savvy is understandable, and the need to keep them entertained will also make sense to many a parent. But we must also weigh up the...

Words: 3718 - Pages: 15

Premium Essay

Tech

...Technology Ventures From Idea to Enterprise is p r bite ohi d. se The pre na limi ry p s age are p are rep d fo r s ent tud s of D ho r. T ma Any s. yer sB oth e e r us se The pre na limi ry p s age are p are rep d fo r s ent tud s of D ho r. T ma Any s. yer sB oth e e r us is p r bite ohi d. Technology Ventures From Idea to Enterprise d. Thomas H. Byers Stanford University se The pre na limi ry p s age are p a Richard C. Dorf . Thom f Dr University of California, Davis so t den stu r d fo Andrew J. Nelson are rep University of Oregon Any s. yer sB oth e e r us is p r bite ohi TECHNOLOGY VENTURES: FROM IDEA TO ENTERPRISE, THIRD EDITION Published by McGraw-Hill, a business unit of The McGraw-Hill Companies, Inc., 1221 Avenue of the Americas, New York, NY 10020. Copyright @ 2001 by The McGraw-Hill Companies, Inc. All rights reserved. Previous editions © 2008 and 2005. No part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written consent of The McGraw-Hill Companies, Inc., including, but not limited to, in any network or other electronic storage or transmission, or broadcast for distance learning. Some ancillaries, including electronic and print components, may not be available to customers outside the...

Words: 60653 - Pages: 243

Free Essay

Mjlfdkjgl

...DARA & SON PVT. LTD Rohini, Sec. 29, New Delhi Research Paper by Manish Bhatt and Prabhudas Lilladher ATTRACTIVE MIDCAPS AMONGST RECENT IPO ISSUES:- [pic]Tech Mahindra and GMR Infrastructure have once again raised interest in the IPO segment. While Tech Mahindra and GMR Infra are obvious choices experts are also bullish on Nectar Life sciences, Unity Infra, All cargo Global and…With over subscription of Voltamp Transformer recently experts give attractive midcap picks from this fraternity for the long-term.   Future business model, sound managements, availability at prices below their issue price, attractive valuations, niche positioning within their industry and future growth are important reasons why investors should log on to these IPOs feel a bevy of experts Money control spoke with.   Apart from that Keynote Capitals in its report titled ‘Attractive Recently Listed Midcap Stocks’ have mentioned names like Nectar Life sciences, Repro India, Talbros Automotive and K Sera.   While a number of them are available at a substantial premium to their offer price, six of them are still quoting at a discount to their issue price.    Everest Kanto looks pretty good at current levels for the long term. All cargo Global also looks good in the recently listed midcap IPOs.   Both the companies are in a niche segment and have done quite well on the fundamentals post-listing. Everest Kanto ranks first as far as LPG cylinder manufacturing is concerned. It posted......

Words: 1132 - Pages: 5

Premium Essay

Tech

...John Weatherwax Week 7 En 1320 Research paper New technology break troughs, Research question, less than 30 years ago we had no cell phones If we can talk on a cell phone that is a watch today and where will we be in 30 more years? Just by what I have seen and heard from various producers of cell phones I do believe that the cell phone tech is going to be in the field of a wearable devices the new (in the last few years ) watches are just the start. In the 50’s Dick Tracy had a watch that the new watches mimic so what is next will it implants or projectable it is hard to tell but in my thoughts it will be in the realm of a wearable and possibly a wearable projection device. Articale #1 Cast your mind back to late 2008, when the first Android-powered handset saw the light of day. Obama won his first Presidential election, Apple launched its App Store (the iPhone had appeared the year before), Google announced its own Chrome browser and we got our first look at the company's new mobile OS on the T-Mobile G1. The Android of 2013 is a world away from that 2008 version, where the Android Market was in its infancy, there were no native video playback capabilities and the G1 had no multi-touch support. But Google is going to have to keep innovating and improving its mobile OS to keep the lion's share of the smartphone market. We've taken a peek into the future to consider what Android might look like in the year 2020. With new Android monikers now appearing about......

Words: 3468 - Pages: 14

Premium Essay

Tech

...eate Value for People II. The Human Side of Business 7. Motivating and Managing People and Groups in Business Organizations © The McGraw−Hill Companies, 2007 234 Chapter Seven SATISFIED CUSTOMERS. Unlike the other moving companies she had seen, Sheets decided that Two Men would put a premium on customer service. “Moving had a cruddy reputation,” she says. “I made sure everything was spotless. And we went out of our way for the customers.” Sheets put her movers in uniforms and gave them business cards, charged by the hour instead of weight, and paid for any damage to be fixed. The company’s mission statement remains: “Treat everyone the way you would want your Grandma treated.” From the start, Sheets handed out postage-paid reply cards, with just five questions, to her cus- tomers. Last year, the company received 66,000 responses. Sheets says that only 1% of the comments are negative—and she uses them as an opportunity. “We want to get it right with our customers,” she says. “Sometimes we send them flowers or a gift if something went wrong.” As a result, Two Men gets about 95% of its business from word-of-mouth refer- rals, eliminating the need for much advertising. With no formal business background, Sheets says she has relied mostly on her own instincts and expe- rience. She credits her time volunteering at a hospital crisis intervention center with helping her to handle customers over the phone. “It taught me empathy and how to listen,” she says. STICK MEN U. When it came...

Words: 1771 - Pages: 8

Free Essay

Case Study Week 5

...QUESTIONS 1. What does this case imply about the supply of and demand for employers and the implications for businesses? The case implies that there is a high demand for employees especially in the high tech industry but the supply is low and has not been met by the volume of the demand making the implications critical for businesses. These organizations are having to step out of the box and go the extra length to ensure they are able to acquire the savvy tech from an early stage. Using tools outside of the normal resume check alongside the educational background, these Companies are able to now “catch them young” by scouting for qualified candidates with needed skills, and recruiting them from colleges instead of waiting till they have completely finished their degree. For instance IBM has made use of its famous Watson computer in certain top schools giving students a chance to challenge the computer. The outcome of these approach will help IBM to narrow down which students to consider and they will work towards luring such students to consider a career at IBM (Robins 2013). As the competition is quite high in this industry, business always have to be creative in their search for talents, be on their toes and pull out all stops in trying to convince potential candidates to choose them instead of their competitors. While some are still struggling to come up with various approach to help them acquire more qualified candidate, the race is still on for the rest in trying to......

Words: 694 - Pages: 3

Premium Essay

Tech

...CHAPTER 16 COST ALLOCATION: JOINT PRODUCTS AND BYPRODUCTS 16-16 (20-30 min.) Joint-cost allocation, insurance settlement. 1. (a) Sales value at splitoff-point method. | |Pounds |Wholesale |Sales |Weighting: |Joint |Allocated | | |of |Selling Price |Value |Sales Value |Costs |Costs per | | |Product |per Pound |at Splitoff |at Splitoff |Allocated |Pound | |Breasts |100 |$1.10 |$110 |0.675 |$ 67.50 |0.6750 | |Wings |20 |0.40 |8 |0.049 |4.90 |0.2450 | |Thighs |40 |0.70 |28 |0.172 |17.20 |0.4300 | |Bones |80 |0.20 |16 |0.098 |9.80 |0.1225 | |Feathers |10 |0.10 |1 |0.006 |0.60 |0.0600 | | |250 | |$163 |1.000 |$100.00 | | Costs of......

Words: 2466 - Pages: 10

Free Essay

Tech

...It is because DMA is an essential feature of all modern computers. It allows devices to transfer data without subjecting the CPU to a heavy overhead. Otherwise, the CPU would have to copy each piece of data from the source to the destination, making the CPU unavailable for other tasks. This situation is aggravated because access to I/O devices over a peripheral bus is generally slower than normal system RAM. With DMA, the CPU gets freed from this overhead and can do useful tasks during data transfer (though the CPU bus would be partly blocked by DMA). In the same way, a DMA engine in an embedded processor allows its processing element to issue a data transfer and carries on its own task while the data transfer is being performed. In another words, when data is transferred between an I/O device and memory in an application system using a microcontroller, the CPU specifies a transfer source address and a transfer destination address in sequence (1-byte units), if an ordinary access is made, and inputs and outputs data. This means that updating the address must be managed and that it takes a long time to transfer data by program processing. When a large amount of data must be processed, therefore, a long time is required. Consequently, the CPU cannot perform processing in time, especially when must process video data and audio data real-time or transfer data with a disk drive. DMA is a technique to speed up data transfer without using the CPU. DMA is executed by......

Words: 301 - Pages: 2

Premium Essay

Tech

...Technology is scientific developments that aid in problem solving and extend human capabilities. Its purpose is to help mankind, but often it has a negative effect. Guns were developed as a tool to protect oneself by killing the enemy. However, they?re often used for murder and on innocent people. Many more people die from the gun than are protected by it. Is the gun something that is harming the human race? Many argue that it is ?people who kill people?, not guns. Even if there weren?t guns, people would kill each other with different means. Although, the invention of something decidedly a weapon cannot be viewed as positive. Leaps and bounds have been made in the medicinal area of technology. Inventions of differing medicines and drugs have promoted the health of millions of people and even saved many of our lives. We no longer fear that influenza will be the death of us, nor any epidemics like the bubonic plague. This does not include third-world countries, which have been neglected and left behind. Not to mention that not all drugs turned out to be good. Many have horrible side effects and have been labeled ?bad? such as marijuana, cocaine, and LSD. Thousands of people are hooked to the stuff in ever downward-spiraling addictions. The internet is a wonderful communication network that connects the world and gives anyone access to billions of faucets of information anytime! With no effort at all you can talk to someone on the other side of the globe or buy something......

Words: 441 - Pages: 2

Free Essay

Tech

...Recent advancements in technology have changed our lives significantly. Most noticeably, they facilitate our living, as evidenced by more effectiveness, efficiency, convenience, and ease which result from their proper application. With the aid of recent advanced technologies, difficult tasks can be accomplished in less time with less effort and energy than they were in the past. However, some people are concerned that the convenience and ease that recent advanced technologies offer affect our humanity. Since technology can facilitate almost all our activities, many people depend more on it than on other people. For example, in big cities, real intimate interpersonal relationship seldom takes place because people devote their time, attention, and money more to their computers, smartphones, and the like, than to social activities with other people. Also in big cities, many children and youths prefer playing videogames solitarily to socializing or doing exercises with their friends. We have to admit that in our modern era, technology is indispensable as well as unavoidable. By nature, everyone wants to live an easy, comfortable, and enjoyable life. Technology can help us create such a life. However, too much dependence on technology can impair our sense of humanity and prevent us from living a healthy, balanced life, just as evidenced by some people’s addiction to the latest products of telecommunication technologies which makes them neglect their families and social......

Words: 308 - Pages: 2

Free Essay

It Tech

...ALCOHOL AND DRUG ABUSE POLICY 1. This information is provided as an example only. Companies are encouraged to use those portions of the attached draft policy applicable to their own operations, to add information specific to their company, and to confer with drug and alcohol enforcement specialists and/or legal counsel in drafting a policy. 2. The sample policy and procedure are based upon accurate information available at the time it was prepared. 3. This sample is not prepared or intended to meet any particular company's needs. 4. A company alcohol and drug abuse policy may create legal rights or liabilities between the parties involved. 5. Legal advice regarding the development or review of this or any employment policy should be obtained. 6. No one should rely solely upon this sample policy outside its intended purpose without first obtaining the appropriate advice of legal counsel. 7. Notes printed in italics are for carrier's reference in drafting its own policy and should not be contained in a company's final policy. Motor Carrier Safety Washington Utilities and Transportation Commission 1300 S. Evergreen Park Dr. SW P O Box 47250 Olympia, WA 98504-7250 Phone: (360) 664-1232 ALCOHOL AND DRUG ABUSE POLICY STATEMENT OF PURPOSE AND POLICY Drivers are an extremely valuable resource for (insert name of company)_____'s business. Their health and safety is a serious Company concern. Drug or......

Words: 6433 - Pages: 26