0 évaluation0% ont trouvé ce document utile (0 vote)
118 vues72 pages
A process can have multiple threads that operate on the same data set. Threads within a process share resources while processes do not. For example, the auto-save and spell check features of a word processing program are different threads of the same process that operate on the same document data.
A process can have multiple threads that operate on the same data set. Threads within a process share resources while processes do not. For example, the auto-save and spell check features of a word processing program are different threads of the same process that operate on the same document data.
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme DOCX, PDF, TXT ou lisez en ligne sur Scribd
A process can have multiple threads that operate on the same data set. Threads within a process share resources while processes do not. For example, the auto-save and spell check features of a word processing program are different threads of the same process that operate on the same document data.
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme DOCX, PDF, TXT ou lisez en ligne sur Scribd
A single process can have multiple threads that share global data and address space with other threads running in the same process, and thereIore can operate on the same data set easily. Processes do not share address space and a diIIerent mechanism must be used iI they are to share data. II we consider running a word processing program to be a process, then the auto-save and spell check Ieatures that occur in the background are diIIerent threads oI that process which are all operating on the same data set (your document). process In computing, a process is an instance oI a computer program that is being sequentially executed |1| by a computer system that has the ability to run several computer programs concurrently. Thread A single process may contain several executable programs (threads) that work together as a coherent whole. One thread might, Ior example, handle error signals, another might send a message about the error to the user, while a third thread is executing the actual task oI the... What is Java object-oriented computer programming? Quick answer Java is an object-oriented computer programming language that is used Ior application as well as system soItware development. It is best Ior web based applications such as servlets, XML design...etc., i.e. the applications that can run on the Internet. It can be used as Iront end tool Ior the back end database application. Ior example, the Iamous Oracle Database management system was designed using Java technology. It is also platIorm independent. meaning it can run under most platIorms and OSs. In-Deptb Answer Java technology was created as a computer programming tool in a small, secret eIIort called "the Green Project" at Sun Microsystems in 1991.
The secret "Green Team," Iully staIIed at 13 people and led by James Gosling, locked themselves away in an anonymous oIIice on Sand Hill Road in Menlo Park, cut oII all regular communications with Sun, and worked around the clock Ior 18 months.
They were trying to anticipate and plan Ior the "next wave" in computing. Their initial conclusion was that at least one signiIicant trend would be the convergence oI digitally controlled consumer devices and computers.
A device-independent programming language code-named "Oak" was the result.
To demonstrate how this new language could power the Iuture oI digital devices, the Green Team developed an interactive, handheld home-entertainment device controller targeted at the digital cable television industry. But the idea was too Iar ahead oI its time, and the digital cable television industry wasn't ready Ior the leap Iorward that Java technology oIIered them.
As it turns out, the Internet was ready Ior Java technology, and just in time Ior its initial public introduction in 1995, the team was able to announce that the Netscape Navigator Internet browser would incorporate Java technology.
Now, nearing its twelIth year, the Java platIorm has attracted over 5 million soItware developers, worldwide use in every major industry segment, and a presence in a wide range oI devices, computers, and networks oI any programming technology.
In Iact, its versatility, eIIiciency, platIorm portability, and security have made it the ideal technology Ior network computing, so that today, Java powers more than 4.5 billion devices: O over 800 mllllon Cs O over 13 bllllon moblle phones and oLher handheld devlces (source Cvum) O bllllon smarL cards O plus seLLop boxes prlnLers web cams games car navlgaLlon sysLems loLLery Lermlnals medlcal devlces parklng paymenL sLaLlons eLc Today, you can Iind Java technology in networks and devices that range Irom the Internet and scientiIic supercomputers to laptops and cell phones, Irom Wall Street market simulators to home game players and credit cards -- just about everywhere.
The best way to preview these applications is to explore java.com, the ultimate marketplace, showcase, and central inIormation resource Ior businesses, consumers, and soItware developers who use Java technology.
Why Software Developers Choose 1ava Technology
The Java programming language has been thoroughly reIined, extended, tested, and proven by an active community oI over Iive million soItware developers.
Mature, extremely robust, and surprisingly versatile Java technology has become invaluable in allowing developers to: O JrlLe sofLware on one plaLform and run lL on pracLlcally any oLher plaLform O CreaLe programs Lo run wlLhln a web browser and web servlces O evelop serverslde appllcaLlons for onllne forums sLores polls P1ML forms processlng and more O Comblne !ava Lechnologybased appllcaLlons or servlces Lo creaLe hlghly cusLomlzed appllcaLlons or servlces O JrlLe powerful and efflclenL appllcaLlons for moblle phones remoLe processors lowcosL consumer producLs and pracLlcally any devlce wlLh a dlglLal hearLbeaL O What is the diIIerence between an Abstract class and InterIace?
Abstract class is Class in Java that has at least one abstract (non-implemented) method deIinition. In an interIace there is no implementation only method declarations.
abstract class Example implements ExampleInterIace public void sum(); public void add()
........; ........; }
}
interface ExampleInterIace
public void sum(); public void add();
} Why should main be declared static and is declaring it public and void not suIIicient? The static modiIier means that it does not have to be instantiated to use it. BeIore a program runs there are technically no objects created yet, so the main method, which is the entry point Ior the application must be labeled static to tell the JVM that the method can be used without having Iirst to create an instance oI that class. Otherwise, it is the "Which came Iirst, the chicken or the egg?" phenomenon. Your main method should be declared as Iollows: public static void main (String|| args) lots oI your java code... } As we know, java is a pure OOP , that means everything should be in the class, main. Aso, because main is itselI a Iunction, static member Iunctions should not reIer to objects oI that class. But we can access static Iunctions through classname itselI, as: class TestMain public static void main(String args||) body; } } Now, cmd~javac TestMain.java cmd~java TestMain as we know the static member Iunctions has to call through its class name. That's why the programme name must be same as the class name ,where we wrote the main Iunction. Another important point is : static variables or member Iunctions will load during class. That means beIore creating any instances(objects), the main Iunction is the Iirst runnable Iunction oI any program which we run manually, such as : cmd~java TestMain(run) iI , any sharing inIormation Is it possible to overload the main method in Java? Yes. The main method can be overloaded just like any other method in Java. The usual declaration Ior main is: public static void main(String|| args) throws Exception; When you launch a java application it looks Ior a static method with the name 'main', return type 'void' and a single argument oI an array oI Strings. ie what you throw is unimportant in resolving this method. Overloading is providing multiple methods with the same name but diIIerent arguments (and potentially return type). The Iollowing class is valid: public class Test public static void main(Object|| o) } public static boolean main(String|| o) } } But when run will result in the error: Exception in thread "main" java.lang.NoSuchMethodError: main Since the methods present does not have the correct signature.(The main method with the void return type is missing. Without it the code cannot be executed by the JVM) Overloading is sometimes conIused with overriding. Overriding is changing the behavior oI a method in a subclass. This is not allowed on a main method because main must be static and is thereIore bound at compile time, not run time, e.g., the program: class A static String Ioo() return "A"; } } class B extends A static String Ioo() return "B"; } } public class Test public static void main(String|| args) A a new B(); System.out.println(a.Ioo()); System.out.println(((B)a).Ioo()); } } Prints: A B This is why it is generally discouraged Irom calling static methods on instance variables. You should always write A.Ioo() or B.Ioo() as this reminds you that there is no polymorphic behavior occurring. What are the advantages oI using user deIined exceptions in Java? UserDeIined exceptions helps throwing an error page depending on the business logic. Suppose that i want to add a user to the system but at the same time somebody has already added the same user and in such senario i want to show a speciI error page to the user so i will extend Irom the ExceptionClass and make a new class and then in my business class i will check the condition and iI the user already exists i will throw a nee insatance oI my own deIined exception class.
What are the disadvantages oI object oriented data model? O UnIamiliarity (causing an added training cost Ior developers). O Inability to work with existing systems (a major beneIit oI C) O Data and operations are separated O No data abstraction or inIo hiding O Not responsive to changes in problem space O Inadequate Ior concurrent problems What does static variable mean? common mlsconcepLlon abouL and mlsuse of Lhe sLaLlc quallfler ls A static variable is program variable that does not vary... go figure.
Static variables have the same value throughout run time. They can be changed at design time only.
1hls ls acLually a beLLer descrlpLlon of Lhe consL modlfler
sLaLlc ls used ln C programs Lo declare a varlable LhaL should exlsL LhroughouL Lhe llfeLlme of Lhe program Jhen Lhe program sLarLs execuLlng all allocaLlons are made for sLaLlc varlables lL has Lhe added sldeeffecL of maklng Lhe varlable noL vlslble ouLslde Lhe scope of Lhe module ln whlch ls declared 1he explanaLlon ln Lhe answer below Lhls one descrlbes Lhls well lor more lnformaLlon speclflc Lo [ava see hLLp//mlndprodcom/[gloss/sLaLlchLml Answer static ls an access quallfler LhaL llmlLs Lhe scope buL causes Lhe varlable Lo exlsL for Lhe llfeLlme of Lhe program 1hls means a static varlable ls one LhaL ls noL seen ouLslde Lhe funcLlon ln whlch lL ls declared buL whlch remalns unLll Lhe program LermlnaLes lL also means LhaL Lhe value of Lhe varlable perslsLs beLween successlve calls Lo a funcLlon 1he value of such a varlable wlll remaln and may be seen even afLer calls Lo a funcLlon Cne more Lhlng ls LhaL a declaraLlon sLaLemenL of such a varlable lnslde a funcLlon wlll be execuLed only once lor usage Lry followlng vold fun() sLaLlc lnL fnvalue0//LxecuLed once prlnLf( ndfnvalue++)// value changed reLalns for nexL call Lhls code behaves llke a sequence generaLor Cne more advanLage of sLaLlc varlables ls LhaL slnce Lhey are creaLed once and Lhen exlsL for Lhe llfe of Lhe program Lhe address of Lhe varlable can be passed Lo modules and funcLlons LhaL arenL ln Lhe same C flle for Lhem Lo access Lhe varlables conLenLs 1hls has several advanLages ln programmlng lor furLher confuslons or deLalls wrlLe me rupesh_[oshl[slfycomrupesh[oshl[gmallcom How do you load a class in Jdbc?
Loading a class in JDBC For getting connection to database and to query database Ior INSERT,UPDATE,DELETE and to do some operations on database through java programs you need to load the jdbc driver class Ior a particular database provided by the database provider Ior that you use class.IorName() Method this method will load the class which are neccessary Ior database operations What is the diIIerence between object-oriented and procedural programming languages? bject rientation Languages (OOL) is concerned to develop an application based on real time while Procedural Programing Languages (PPL) are more concerned with the processing oI procedures and Iunctions. In OOL, more emphasis is given on data rather than procedures, while the programs are divided into Objects and the data is encapsulated (Hidden) Irom the external environment, providing more security to data which is not applicable or rather possible in PPL. In PPL, its possible to expose Data and/or variables to the external entities which is STRICTLY restricted IN OOL. In OOL, the Objects communicate with each other via Functions while there is no communication in PPL rather its simply a passing values to the Arguments to the Functions and / or procedures. OOL Iollows Bottom Up Approach oI Program Execution while in PPL its Top Down approach. OOL concepts includes Inheritance, Encapsulation and Data Abstraction, Late Binding, Polymorphism, Multithreading, and Message Passing while PPL is simply a programming in a traditional way oI calling Iunctions and returning values. Below is the list oI OOL languages :- JAVA, VB.NET, C#.NET Below is the list oI PPL languages :- C, VB, Perl, Basic, FORTRAN.
What is the diIIerence between object oriented programming and procedure oriented programming? n POP, importance is given to the sequence oI things to be done i.e. algorithms and in OOP, importance is given to the data. In POP, larger programs are divided into Iunctions and in OOP, larger programs are divided into objects. In POP, most Iunctions share global data i.e data move Ireely around the system Irom Iunction to Iunction. In OOP mostly the data is private and only Iunctions inside the object can access the data. POP Iollows a top down approach in problem solving while OOP Iollows a bottom up approach. In POP, adding oI data and Iunction is diIIicult and in OOP it is easy.
In POP, there is no access speciIier and in OOP there are public, private and protected speciIier.
In POP, operator cannot be overloaded and in OOP operator can be overloaded.
In POP, Data moves openly around the system Irom Iunction to Iunction, In OOP objects communicate with each other through member Iunctions
What is the diIIerence between throw and throws in Java? ne declares it, and tbe otber one does it Throw is used to actually throw the exception, whereas throws is declarative Ior the method. They are not interchangeable. public void myMethod(int param) throws MyException
lf (param 10)
Lhrow new MyLxcepLlon(1oo low!)
//8lah 8lah 8lah } The Throw clause can be used in any part oI code where you Ieel a speciIic exception needs to be thrown to the calling method. II a method is throwing an exception, it should either be surrounded by a try catch block to catch it or that method should have the throws clause in its signature. Without the throws clause in the signature the Java compiler does not know what to do with the exception. The throws clause tells the compiler that this particular exception would be handled by the calling method. What is JNI? Java Native InterIace
JNI is an interIace between java and applications and libraries written in other languages. As an example, JNI enables Java programs to use C libraries and also enables C programs to use Java classes.
What does the garbage collector do in Java and how does it work? Memory management is a crucial element in many types oI applications. Consider a program that reads in large amounts oI data, say Irom somewhere else on a network, and then writes that data into a database on a hard drive. A typical design would be to read the data into some sort oI collection in memory, perIorm some operations on the data, and then write the data into the database. AIter the data is written into the database, the collection that stored the data temporarily must be emptied oI old data or deleted and recreated beIore processing the next batch. This operation might be perIormed thousands oI times, and in languages like C or C that do not oIIer automatic garbage collection, a small Ilaw in the logic that manually empties or deletes the collection data structures can allow small amounts oI memory to be improperly reclaimed or lost Iorever. These small losses are called memory leaks, and over many thousands oI iterations they can make enough memory inaccessible that programs will eventually crash. Creating code that perIorms manual memory management cleanly and thoroughly is a complex task. Java's garbage collector provides an automatic solution to memory management. In most cases it Irees you Irom having to add any memory management logic to your application. The downside to automatic garbage collection is that you can't completely control when it runs and when it doesn't.
verview of 1ava's Garbage Collector
Garbage collection is the phrase used to describe automatic memory management in Java. Whenever a soItware program executes (in any programming language Ior that matter), it uses memory in several diIIerent ways. We're not going to get into Computer Science 101 here, but it's typical Ior memory to be used to create a stack, a heap, in Java's case constant pools, and method areas. The heap is that part oI memory where Java objects live, and it's the one and only part oI memory that is in any way involved in the garbage collection process.
So, all oI garbage collection revolves around making sure that the heap has as much Iree space as possible. For the purpose oI the exam, what this boils down to is deleting any objects that are no longer reachable by the Java program running. When the garbage collector runs, its purpose is to Iind and delete objects that cannot be reached. II you think oI a Java program as being in a constant cycle oI creating the objects it needs (which occupy space on the heap), and then discarding them when they're no longer needed, creating new objects, discarding them, and so on, the missing piece oI the puzzle is the garbage collector. When it runs, it looks Ior those discarded objects and deletes them Irom memory so that the cycle oI using memory and releasing it can continue. When comparing java.io.BuIIeredWriter to java.io.FileWriter which capability exists as method in only one oI the two? BuIIeredWriter is the class which has a method called newLine() which actually writes a platIorm speciIic new line character and this method is not there in FileWriter class Why is Java called an Object Oriented Programming Language? Because it implements object oriented programming concepts like inheritance, polymorphism, encapsulation, abstraction, polymorphism etc etc.
What is the deIinition oI binding? Law. To place under legal obligation by contract or oath. Chemistry. To combine with, Iorm a chemical bond with, or be taken up by, as an enzyme with its substrate. What do you mean by platIorm independent? The word "platIorm independent" means that the source code written in one language can be run on any machine independent oI any hardware platIorm with minimal or no changes. Note: There are comments associated with this question. See the discussion page to add to the conversation. Why do Iile name and class name always coincide in Java?
First oI all, it only has to be the same when the class is public. And there is no explicit reason Ior that, it's just a convention that came along with old versions oI java and people got used to it... They say it's because oI the limited capabilities oI the compiler to compile dependencies. Article When packages are stored in a Iile system (?7.2.1), the host system may choose to enIorce the restriction that it is a compile-time error iI a type is not Iound in a Iile under a name composed oI the type name plus an extension (such as .java or .jav) iI either oI the Iollowing is true: O 1he Lype ls referred Lo by code ln oLher compllaLlon unlLs of Lhe package ln whlch Lhe Lype ls declared O 1he Lype ls declared publlc (and Lherefore ls poLenLlally accesslble from code ln oLher packages) This restriction implies that there must be at most one such type per compilation unit. This restriction makes it easy Ior a compiler Ior the Java programming language or an implementation oI the Java virtual machine to Iind a named class within a package; Ior example, the source code Ior a public type wet.sprocket.Toad would be Iound in a Iile Toad.java in the directory wet/sprocket, and the corresponding object code would be Iound in the Iile Toad.class in the same directory. When packages are stored in a database (?7.2.2), the host system must not impose such restrictions. In practice, many programmers choose to put each class or interIace type in its own compilation unit, whether or not it is public or is reIerred to by code in other compilation units. Answer It is not mandatory to say "Iile name equals to classname". ~ U can give your own name to your Iilename | other than classname | ~ at the time oI compilation you just give your Iilename|other than classname| ~ AIter compilation you will get .class Iile with your class name.|classname.class| ~.But at the time oI loading ur program into JVM u just have to give the class name , This is possible even the main() is public/private. Ior eg:-consider have created a program in java with Iile name Ashish n class name is batra,now at the time oI compilation u have to write "javac ashish.java" at the command prompt and at the same time the jvm create the .class object in the bin directory with Iilename batra(batra.class) .Now at the time oI running the program u have to write "java batra" at the command prompt. We say this statment that the Iile name should be same as the class name to make sure there is no conIusion while compiling n running the program .Consider u have created many programs in java and now u want to run any one oI them ,then it would be very diIIicult Ior u to recall the class name oI that particular program .So to make it a simpler we oIIenly say that the class name should be same as the Iile name. Why multiple inheritance is not possible in java? Let me explain with a example.
Suppose consider a method IunX() which is in class Z.
Suppose a programmer ABC inherited the class Z to class X and overrided the IunX().So this class will have the new implementation oI IunX(). Suppose a programmer DEF inherited the class Z to class Y and overrided the IunX().So this class will have the new implementation oI IunX().
II Multiple Inheritance is permitted in java, then iI the new programmer inherited both the classes and he didn't done any overriding oI method IunX() then iI he calls the IunX() ,the JVM will not know which method to call i.e., either the method in class X or method in class Y.
Because oI this inconsistencies,Multiple inheritance is not permitted in java. Note: There are comments associated with this question. See the discussion page to add to the conversation. Why don't you use pointers in Java? You do not use pointers in Java because the language designers decided to abstract memory management to a higher level in Java than in C. The reason Ior this is that it is easy to make mistakes using pointers and other lower level memory management techniques. These mistakes can lead to bugs. hard to read code, memory leaks that waste system resources, and security issues. Instead Ior the most part Java takes care oI memory management Ior the user who can instead speciIy behavior though the object oriented techniques that are saIer and easier to understand. The downside is that the programmers lose some control and Ilexibility in using memory. Also, programs using Java take a small perIormance hit in some cases because oI the extra work Java has to do to manage memory itselI. What is object oriented programming? Programming real world entities as classes that have data members and member Iunctions to operate on those data members, with rich Iunctionalities such as abstraction, inheritance and polymorphism is called object oriented programming. An object is nothing but an instance oI a class. abstraction reIers to hiding the complicated details oI a program while presenting a simpliIied interIace to the user thus enabling him to use the Iunctionalities without bothering about how they were implemented internally. inheritance: where one class can inherit properties oI another class thus helping in reuse oI code. polymorphism: meaning one name many Iunctions, like area() which could be used to calculate area oI a circle or triangle or square on the basis oI parameters passed to it. user-generated content: report abuse
What is a vector in Java?
Vector is a type oI collection object that Java has. Vector is a class that implements the AbstractList class and is oIten used as an alternative to arrays since it automatically extends the length oI the list unlike arrays. A Vector can contain a collection oI objects oI any type. But it has Iallen out oI use due to the rise oI the more convenient ArrayList class, but Vectors are still used Ior their security in multi threaded environment. Vectors are thread saIe but array lists are not. An important Iact to note is that Stack extends the Vector class. What is dependency injection and how is it implemented in Java? Such a pattern involves at least three elements: adependent, its dependencies and an injector (sometimes reIerred to as a provider or container). The dependent is a consumer that needs to accomplish a task in a computer program. In order to do so, it needs the help oI various services (the dependencies) that execute certain sub-tasks. The provider is the component that is able to compose the dependent and its dependencies so that they are ready to be used, while also managing these objects' liIe-cycles. This injector may be implemented, Ior example, as a service locator, an abstract Iactory, a Iactory method or a more complex abstraction such as a Iramework. The Iollowing is an example. A car (the consumer) depends upon an engine (the dependency) in order to move. The car's engine is made by an automaker (the dependency provider). The car does not know how to install an engine into itselI, but it needs an engine in order to move. The automaker installs an engine into the car and the car utilizes the engine to move. When the concept oI dependency injection is used, it decouples high-level modules Irom low- level services. The result is called the dependency inversion principle. public interface Engine public float getEngineRPM(); public void setFuelConsumptionRate(float IlowInGallonsPerMinute); } public interface Car public float getSpeedInMPH(); public void setPedalPressure(float pedalPressureInPounds); }
What does it mean to say that Java is portable? Java is known as a portable language because Java code can currently execute on all major platIorms. What's more, once you've compiled your Java source Iiles to .class Iiles, those Iiles can be used on any Java-supported platIorm without modiIication, unlike many other languages. Because application sorIware written by JAVA can run on any platIorm just with a JAVA compiler.Java compiler will compile you java codes to byte-code,but not machine-code.So you can run it on every platIorm. Is it possible to override the main method in Java? static method can be overide.it is should be possible. example
class madd public static void main(String args||) }
}
public class mohit extends madd public static void main(String args||) System.out.println("HELLO"); }
}
compile succeIully and run also.then output will be HELLO
This perception is wrong. In actual, static methods are hidden, not overriden. The above example, actually hides the derived method implementation oI main() Irom base class method implememntation. This is hiding. It will compile, as it is syntactically correct but as concept wise, this is hiding. Why thread is called lightweight process? A thread is similar to a separate process, in that it can do stuII (process) independently oI other threads. But it is lightweight, since the operating system doesn't have to give it its own memory space, since it shares memory with the other threads in the process What is the diIIerence between exception and error in java? Error: Any departure Irom the expected behavior oI the system or program, which stops the working oI the system is an error.
Exception:Any error or problem which one can handle and continue to work normally.
Note that in Java a compile time error is normally called an "error," while a runtime error is called an "exception. When does Garbage collection occur in java? No one can Iorce garbage collector to Iree memory, A java object is subjected to garbage collection when it can not be reached by the program in which it is being used. Programmer can request Ior garbage collection by System.gc() but JVM doesn't guarantee that is will start immediately What is a java virtual machine? An abstract computing machine, or virtual machine, JVM is a platIorm-independent programming language that converts Java bytecode into machine language and executes it. Most programming languages compile source code directly into machine code that is designed to run on a speciIic microprocessor architecture or operating system, such as Windows or UNIX. A JVM -- a machine within a machine -- mimics a real Java processor, enabling Java bytecode to be executed as actions or operating system calls on any processor regardless oI the operating system. For example, establishing a socket connection Irom a workstation to a remote machine involves an operating system call. Since diIIerent operating systems handle sockets in diIIerent ways, the JVM translates the programming code so that the two machines that may be on diIIerent platIorms are able to connect. What is heap size in Java? ava heap is the heap size allocated to JVM applications which takes care oI the new objects being created. II the objects being created exceed the heap size, it will throw an error saying memoryOutoI Bound Java's deIault heap size limit is 128MB. II you need more than this, you should use the -Xms and -Xmx command line arguments when launching your program: java -Xms -Xmx We can also give like in this Iormat also.Iormat is : -mx256m..Sometimes it will show error iI you are using java -Xms -Xmx Iormat..In that case use -mx256m this.value can be changed.. What is metadata? Consider a Iile with a picture. The picture or the pixels inside the Iile are data. A description oI the picture, like "JPEG Iormat, 300x400 pixels, 72dpi", is metadata, because it describes the content oI the Iile, although it's not the actual data What are advantages and disadvantages oI OOP 'Object Oriented Programming'? The advantages are Data Encapsulation Data Hiding Easy to maintain the code Reuseability oI classes
And disadvantages are wastage oI time in case oI small projects or codes What is markable interIace in java? !ava rogrammlng LdlL caLegorles ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads lmprove nswer Answer
1he lnLerface whlch doesnL have any declaraLlons of meLhods are called Lhe markable lnLerface (or marker lnLerface)
1hey are named marker lnLerfaces because Lhelr only purpose ls Lo mark speclal classes
Lxamp|e ln Lhe !ava l Lhere ls Lhe lnLerface clooeoble Slnce Object already has Lhe meLhod clooe() Lhe clooeoble lnLerface ls empLy and ls only used Lo mark classes whlch ob[ecLs are allowed Lo clone 1here are 1hree marker lnLerfaces LhaL are er|a||zab|ekemote and C|oeab|e
8ead more hLLp//wlklanswerscom/C/JhaL_ls_markable_lnLerface_ln_[ava#lxzz1SsCqgvL explain the database system environment and classiIy the database management system'? !ava rogrammlng CompuLer Sclence Cracle aLabase LdlL caLegorles esign for Environmentwww.productecologyonline.com Life cycle thinking for designers. Free Trial Accounts. Register now. Ads lmprove nswer Answer distributed computing
8ead more hLLp//wlklanswerscom/C/explaln_Lhe_daLabase_sysLem_envlronmenL_and_classlfy_Lhe_daLabase_ managemenL_sysLem#lxzz1Ss1shpZ What is the diIIerence between event driven languages and procedural languages? !ava rogrammlng nL1 rogrammlng LdlL caLegorles SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Ads lmprove nswer Answer hi, the answer Ior the above mention question goes like this............
The event driven programming in oops language is very conceptual programig concept, in the event driven program, the user can interact with the user interIace by making use oI mouse or any other means oI controls ' But in procedural programming , you cannot interact with the user interIace through any oI the control, u can only and solely interact with the user interIace through codes............ so its is rather diIIicult Ior the user to interact the user interIace through codes
8ead more hLLp//wlklanswerscom/C/JhaL_ls_Lhe_dlfference_beLween_evenL_drlven_languages_and_procedur al_languages#lxzz1SsJz[cz What does 'void' mean in the statement public static void in Java? n: Java Programming |Edit categories| ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads Improve Answer: When you attach a void to a method, it means that method doesnt have to return anything. It will then just execute when called upon.
Read more: http://wiki.answers.com/Q/Whatdoes'void'meaninthestatementpublicstaticvoidinJa va#ixzz1PSsZB5Pg What is the diIIerence between Jar and Ear and War Iiles? n: Java Programming, SoItware Engineering, Computer Science |Edit categories| TecH IT Education, Blorewww.dtech-education.com 11g BA, SQL, PL/SQL courses by 12+ Exp IT Experts- 9741431318 Ads Improve Answer: JAR Iiles (1ava ARchive) allows aggregating many Iiles into one, it is usually used to hold Java classes in a library. i.e. Math.jar
WAR Iiles (Web Application aRchive) stores XML, java classes, and JavaServer pages Ior Web Application purposes.
EAR Iiles (Enterprise ARchive) combines JAR and WAR Iiles to make a combined archive Ior Enterprise Applications.
Read more: http://wiki.answers.com/Q/WhatisthediIIerencebetweenJarandEarandWarIiles#ixzz1 PSsal1z9 Why is Java more secure than other languages? !ava rogrammlng LdlL caLegorles SAP Certification @ NIITNIIT.com/SAPeducation Enrol in 4 weeks SAP Program. Build yourself a better Career. Ads lmprove nswer Answer !ava ls consldered more secure Lhan oLher languages for several reasons O 1he !ava compller caLches more complleLlme errors oLher languages (llke C++) wlll complle programs LhaL produce unpredlcLable resulLs O !ava does noL allocaLe dlrecL polnLers Lo memory 1hls makes lL lmposslble Lo accldenLally reference memory LhaL belongs Lo oLher programs or Lhe kernel
My answer may dlffer
!avas securlLy model ls focused on proLecLlng users from programs downloaded from sources across a neLwork !ava programs run ln !ava 8unLlme LnvlronmenL !ava rograms canL Lake any acLlon ouLslde Lhose boundarles lor example rogramms are prohlblLed from many acLlvlLles lncludlng
* 8eadlng or wrlLlng Lo Lhe local dlsk * Maklng a neLwork connecLlon Lo any hosL excepL Lhe hosL from whlch Lhe appleL came * CreaLlng a new process * Loadlng a new dynamlc llbrary and dlrecLly calllng a naLlve meLhod
8ead more hLLp//wlklanswerscom/C/Jhy_ls_!ava_more_secure_Lhan_oLher_languages#lxzz1SseLx What is a java constructor? n: Computer Hardware, Java Programming |Edit categories| ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads Improve Answer: A constructor creates an Object oI the class that it is in by initializing all the instance variables and creating a place in memory to hold the Object. It is always used with the keyword new and then the Class name. For instance, new String(); constructs a new String object. Sometimes in a Iew classes you may have to initialize a Iew oI the variables to values apart Irom their predeIined data type speciIic values. II java initializes variables it would deIault them to their variable type speciIic values. For example you may want to initialize an integer variable to 10 or 20 based on a certain condition, when your class is created. In such a case you cannot hard code the value during variable declaration. such kind oI code can be placed inside the constructor so that the initialization would happen when the class is instantiated.
Read more: http://wiki.answers.com/Q/Whatisajavaconstructor#ixzz1PSsgc3ca Why java not support operator overloading? n: Java Programming |Edit categories| Ab-Initio Experts Neededwww.accenture.com Submit Your CV for Ab-Initio Career Opportunities with Accenture India. Ads Improve Answer: Maybe because Sun said so. We have to bear with so many other idiosyncrasies too. But I guess that comes with every language.
There were two major reasons why operator overloading wasn't allowed in Java: "cleanliness" and VM complexity.
Operator overloading, while useIul, can be exceedingly conIusing, much more so than method overloading. Given the human tendency to assign speciIic meanings to single symbols, it is hard to get programmers to wrap their heads around multiple meanings Ior operators. What this means is that there is a marked increase in programming errors when a language supports operator overloading. Since practically the same beneIit can be obtained via methods, the Java designers decided that the increased programmer mistake rate was not worth supporting operator overloading.
From a VM design standpoint, supporting operator overloading is considerably more diIIicult than method overloading, requiring a more complex VM. In addition, operator overloading generally will produce a slower VM than one which doesn't support it, mostly due to the extra checks that operator overloading requires inside the VM.
Read more: http://wiki.answers.com/Q/Whyjavanotsupportoperatoroverloading#ixzz1PSsj5Ir1 DiIIerence between java bean and bean? n: Java Programming |Edit categories| SAP Certification @ NIITNIIT.com/SAPeducation Enrol in 4 weeks SAP Program. Build yourself a better Career. Ads Improve Answer: A Java Bean is a soItware component written in the Java programming language that conIorms to the JavaBeans component speciIication. The JavaBeans APIs became part oI the "core" Java APIs as oI the 1.1 release oI the JDK. The JavaBeans speciIication deIines a Java-based soItware component model that adds a number oI Ieatures to the Java programming language. Some oI these Ieatures include: O introspection O customization O events O properties O persistence Enterprise JavaBeans (EJBs) are Java-based soItware components that are built to comply with Java's EJB speciIication and run inside oI an EJB container supplied by a J2EE provider. An EJB container provides distributed application Iunctionality such as transaction support, persistence and liIecycle management Ior the EJBs.
Read more: http://wiki.answers.com/Q/DiIIerencebetweenjavabeanandbean#ixzz1PSsloBSG What is the diIIerence between a Iunction and a subroutine? n: Computer Programming, Java Programming, Visual Basic Programming, The DiIIerence Between |Edit categories| SAP Certification @ NIITNIIT.com/SAPeducation Enrol in 4 weeks SAP Program. Build yourself a better Career. Ads Improve Answer: A Iunction returns a value whereas a subroutine does not. A Iunction should not change the values oI actual arguments whereas a subroutine could change them.
Read more: http://wiki.answers.com/Q/WhatisthediIIerencebetweenaIunctionandasubroutine#ixzz 1PSsoQNWV What is a copy constructor? !ava rogrammlng LdlL caLegorles SAP Mm Employmentwww.accenture.com/SAP Opportunities for SAP MM Experts. View obs & Submit Your CV Now. Ads lmprove nswer Answer A copy constructor is a type oI constructor which constructs the object oI the class Irom another object oI the same class. The copy constructor accepts a reIerence to its own class as a parameter. A valid copy constructor can be speciIied as, class A ...... ...... public: A(&A); }
8ead more hLLp//wlklanswerscom/C/JhaL_ls_a_copy_consLrucLor#lxzz1SsqCZ84 What do you mean by data type in Java? CompuLer 1ermlnology !ava rogrammlng LdlL caLegorles SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Ads lmprove nswer Data type: a set of values togetber witb a set of operations Answer A category oI storing inIormation/data that may or may not be interchangeable. An int is a data type, as is boolean. Each class is also considered its own data type. In real liIe, "Iruit" would be considered a data type, as would "number". Comparing a Iruit to a number does not work, since they're not oI the same data type. Unless you have a way to convert the Iruit into a number, or the number into a Iruit, they are incompatible. In java, an "int" would be considered a data type, as would "boolean". Comparing an int to a boolean does not work - is 3 the same as true? The data types aren't compatible. Some common data types available in Java are: 1. int, Iloat, double etc - Used to store numbers 2. String - Used to store alpha numeric values like Names, address etc 3. Boolean - used to store logical values like true/Ialse
8ead more hLLp//wlklanswerscom/C/JhaL_do_you_mean_by_daLa_Lype_ln_!ava#lxzz1Sssyr98 What is Jdbc and how you connect Java with database? n: Java Programming |Edit categories| SAP Certification at NIITNIIT.com/SAP Enhance Your SAP Understanding with Our SAP Training Modules. Enroll! Ads Improve Answer: JDBC mean Java Database Connectivity. In java, using JDBC drivers, we can connect to database. Steps to connect to JDBC. 1) Load the driver, using Class.IorName(DriverName); 2) Get the connection object, Connection con Driver.getConnection(loaded driver name); 3) Create a SQL statement, Statement s con.createStatement(); 4) Create Resultset object using the statement created above, ResultSet rs s.executeQuery("sql statement");
Iterate the result set to get all the values Irom the database.
Finally don't miss this 5) s.close(); 6) con.close() ;
Read more: http://wiki.answers.com/Q/WhatisJdbcandhowyouconnectJavawithdatabase#ixzz1PSs vHQMn What are objects and how are they created Irom a class in Java? CompuLer SofLware and ppllcaLlons !ava rogrammlng CompuLer Sclence LdlL caLegorles SAP Certification at NIITNIIT.com/SAP Enhance Your SAP Understanding with Our SAP Training Modules. Enroll! Ads lmprove nswer Answer Literally, an object in programming is a collection oI data and Iunctions (remember that Iunctions just bits oI data, too). An object's class deIines what those data and Iunctions are and how to make new objects oI that class.
So a class is like a cast to make a plastic toy and an object is like a single plastic toy itselI.
8ead more hLLp//wlklanswerscom/C/JhaL_are_ob[ecLs_and_how_are_Lhey_creaLed_from_a_class_ln_!ava#lxzz 1SsxveC What is JBoss? !ava rogrammlng LdlL caLegorles SmartobBoardwww.SmartobBoard.com Customizable ob Board Software Supports VIEO, SEO friendly... Ads lmprove nswer Answer JBoss is an open source project, sponsored by Red Hat, aimed at building a Java-based middleware application server. An application server is a soItware engine that delivers applications to client computers or devices. The main beneIit oI an application server is the ease oI application development, since applications need not be built Irom scratch, but are assembled Irom building blocks provided by the application server. Middleware is a piece oI soItware that connects two or more soItware applications so that they can exchange data.
8ead more hLLp//wlklanswerscom/C/JhaL_ls_!8oss#lxzz1Sszk8Mk What in java is not serializable? n: Java Programming |Edit categories| ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads Improve Answer: Objects that do not implement Serializable.
Read more: http://wiki.answers.com/Q/Whatinjavaisnotserializable#ixzz1PSt2Atuo What is the diIIerence between pass by value and pass by reIerence in c? n: Java Programming |Edit categories| SAP Mm Employmentwww.accenture.com/SAP Opportunities for SAP MM Experts. View obs & Submit Your CV Now. Ads Improve Answer: Pass By Reference : n Pass by reference address of the variable is passed to a function. Whatever changes made to the formal parameter will affect to the actual parameters - Same memory location is used for both variables.(Formal and Actual)- - it is useful when you required to return more then 1 values Pass By Value: - n this method value of the variable is passed. Changes made to formal will not affect the actual parameters. - Different memory locations will be created for both variables. - Here there will be temporary variable created in the function stack which does not affect the original variable.
Read more: http://wiki.answers.com/Q/WhatisthediIIerencebetweenpassbyvalueandpassbyreIer enceinc#ixzz1PSt3k3d8 Why would you want to use user deIined exception handling? n: Java Programming |Edit categories| SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Ads Improve Answer: sometimes there are situations where the program is vary long which can make error debugging a long process so java provides a Iacility to make user deIined exception handling suppose we are dividing two numbers a/b and iI the user enters the value oI b 0, the user wants to display an error oI your own so the user can do this by using exception handling
Read more: http://wiki.answers.com/Q/WhywouldyouwanttouseuserdeIinedexceptionhandling#ix zz1PSt5l9ZG Why is Java not a pure OOP Language? !ava rogrammlng LdlL caLegorles ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads lmprove nswer Answer !ava ls a CC language and lL ls noL a pure Cb[ecL 8ased rogrammlng Language
Many languages are Cb[ecL CrlenLed 1here are seven quallLles Lo be saLlsfled for a programmlng language Lo be pure Cb[ecL CrlenLed 1hey are 1 LncapsulaLlon/aLa Pldlng lnherlLance 3 olymorphlsm 4 bsLracLlon 3 ll predlflned Lypes are ob[ecLs 6 ll operaLlons are performed by sendlng messages Lo ob[ecLs 7 ll user deflned Lypes are ob[ecLs
!v ls noL because lL supporLs rlmlLlve daLaLype such as lnL byLe long eLc Lo be used whlch are noL ob[ecLs ConLrasL wlLh a pure CC language llke SmallLalk where Lhere are no prlmlLlve Lypes and boolean lnL and meLhods are all ob[ecLs Note: There are comments associated with this question. See the discussion page to add to the conversation.
8ead more hLLp//wlklanswerscom/C/Jhy_ls_!ava_noL_a_pure_CC_Language#lxzz1SL88vof nswerscom Jlkl nswers CaLegorles 1echnology CompuLers CompuLer rogrammlng !ava rogrammlng JhaL do you mean when you say LhaL !ava has Lwo concepLs? usergeneraLed conLenL reporL abuse
What do you mean when you say that Java has two concepts? !ava rogrammlng LdlL caLegorles ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads lmprove nswer Answer You are talking about the implementation point view oI Abstract class and the interIace. Let's go. 1. InterIace helps Multiple inheritance:- In java you can't have a class inherited Irom more than one class, i.e. the multiple inheritance. InterIace helps us in implementing the multiple inheritance(virtually), because their is no such restriction in implementing more than one interIace. But the Abstract class can't help you doing so. 2. InterIace helps global declaration:- In C/C, a header Iile holds the declaration oI the Iunctions and the symbolic constants. Similarly we can have a interIace which is having only the symbolic constants which is same Ior all classes which implements it. And also the method have only the signature and the class which implements it is Iree to write the body at his own wish. Abstract class can't help in doing this. 3. Abstract class is more secure:- Because in InterIace we have all the things public. But in Abstract class we can have private and also Iriendly members. 4. InterIace is overhead:- Because in InterIace we are bound to implement all the methods though some oI them we actually need. But in case oI the Abstract class we can override the methods which we want.
8ead more hLLp//wlklanswerscom/C/JhaL_do_you_mean_when_you_say_LhaL_!ava_has_Lwo_concepLs#lxzz1 SLv1u What are user defined exceptions in 1ava? ln CompuLer SofLware and ppllcaLlons CompuLer rogrammlng !ava rogrammlng LdlL caLegorles nswer Answer Java supports exception handling by its try catch constructs. Exceptions are conditions which the JVM or applications developed in Java are unable to handle. The Java API deIines exception classes Ior such conditions. These classes are derived Irom java.lang.Throwable class. User deIined exceptions are those exceptions which an application provider or an API provider deIines by extending java.lang.Throwable class. Answer There could be a exception which cannot reach the user as it looks, instead it could be replaced by some other exceptions. In this case, the only solutions is to write our own exception and show the details regarding that exception. i saw one oI the example :: Exceptions could be thrown inside a Web Service Ior various reasons. The possible types oI exceptions that could be thrown are RuntimeException, RemoteException, SOAPFaultException and User DeIined Exception. The Web Service developer might try throwing a RuntimeException such as NullPointerException or ArrayIndexOutOIBoundsException inside the Web Service. But, throwing RuntimeException inside the Web Service is considered to be a bad exercise because RuntimeException will always be converted into RemoteException at the client side. While the client is waiting to catch the RuntimeException aIter invoking a Web Service, he will get only the RemoteException instead oI RuntimeException. Eventually, he cannot perIorm proper error handling Ior RuntimeException. The problem with throwing RemoteException is that the diIIerent client side libraries will interpret this exception in diIIerent ways. It is not portable. The appropriate exception that the Web Service application could throw is SOAPFaultException. The SOAPFaultException contains Iour parts: Iaultcode, Iaultstring, actor, and detail. This exception can give you the complete inIormation about the error condition. The Iaultcode might tell you whether the error has happened because oI the Server, Client, or something else. For example, when a client doesn't provide security inIormation such as username and password in the HTTP/SOAP header but the service mandates them, the pre-processing logic in the service implementation might obviously throw an authentication exception. This kind oI error is considered to be a Client error. The Iaultstring contains the corresponding description oI the error condition that has happened. This string message is human readable and the developer can easily debug the problem with the help oI it. The detail element contains the actual exception message and its complete stack trace. Actually, the detail element is an instance oI the javax.xml.soap.Detail class and can be created by using the javax.xml.soap.SOAPFactory.createDetail() API. User-DeIined Exceptions Although SOAPFaultException gives necessary inIormation that is needed to debug the problem, the Web Service client might want to do something more with a Iault message that he had received. The one thing that he might want to do is to have a conIigurable and dynamic text description oI the error that occurred. The other thing could be to have the internationalization support Ior the error messages. By providing text description in languages other than English, he could try addressing needs oI all set oI people. The list may grow more and more. To achieve the previously stated goals, a user-deIined exception with some speciIic Iormat could be thrown in the service. Based on the exception that the client has received, he can decide what to do with Iault message. The user-deIined exception thrown inside the Web Service is directly mapped into wsdl:Iault element in the Web Services Description Language (WSDL) oI the Web Service. You could see the Iault element as one oI the child elements oI operation element oI the portType. The other two child elements oI operation are input and output. The Iault element, an optional Iield in the operation element, deIines the abstract Iormat oI the error message that might be thrown by the Web Service. The wsdl:message element pertaining to WSDL:Iault can contain only one message part, and the message part could be either a complexType or simple XMLType. I propose here how a user-deIined exception, MyCustomException, could be deIined to better handle error messages. The MyCustomException contains an appropriate Iault message that is as deIined in the WSDL deIinition. The Iault message contains the Iollowing three parts: Error Code, containing a Iive-letter identiIier plus a three-digit identiIier For example, GENEX001 could mean a generic error, whereas AUTEX001 could mean an authentication error. Text describing the Iault, including substitution variables (mentioned as 0}, 1}, and so Iorth) For example, the corresponding text description Ior Error Code GENEX001 will be something like "Number that you have entered is 0}." A list oI values corresponding to the substitution variables deIined in the above text. For example, Ior the above case, the variable list will contain only one value (say 1) because the text description above contains only one substitution variable. AIter processing the text using relevant logic, the Iinal text description would be "Number that you have entered is 1." With the above approach: Faults can be identiIied, using the error code, without the need Ior applications or people to parse or understand the Iault text (which may be in a unknown language). Text description can be deIined in many languages, and corresponding variables can be placed accordingly in a language-independent manner. Internationalization support can be oIIered by the Services by providing alternate language Iorms oI Iault messages automatically by replacing the text description portion only. Sample: Service, Exception Class, WSDL, and Client In this section, you will see a sample Ior service, exception, WSDL, and client. These samples will use Weblogic implementation. Service Implementation This service takes two inputs: int number and String message. II the number is 1, SOAPFaultException will be thrown. II the number is 2, MyCustomException will be thrown; otherwise, the method will return successIully. package WS.exception; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPFactory; import javax.xml.soap.Detail; public class ExceptionService public String echo(int number, String message) throws MyCustomException System.out.println("Number: "number", Message: " message); switch(number) case 2: throw new MyCustomException( "GENEX001", "Number that you have entered is 0}", new String||String.valueOI(number)} ); case 1: Detail detail null; try detail SOAPFactory.newInstance().createDetail(); //add error message here detail.addTextNode( "Choice 1 means SOAPFaultException"); }catch(SOAPException ex) throw new MyCustomException( "SEREX001", "Error while creating detail element", new String()}); } throw new javax.xml.rpc.soap.SOAPFaultException( new javax.xml.namespace.QName("env.Server"), "Number that you have entered is "number, "NO ACTOR", detail); } return "SUCCESS"; } } I would like to make you understand the concept using a very simple code import java.lang.RuntimeException; class MyException extends RuntimeException MyException(String str) super(str); } } class testRunTime void calculate() throws MyException try int x0; int i10/x; }catch(MyException e) e.printStackTrace(); } } public static void main(String aa||) testRunTime ttnew testRunTime(); tt.calculate(); } } just copy paste these code and run to understand what's the logic behind it with cheers Maneesh K Sinha ph-91-9867302855 Answer Since Java is an Object Oriented programming language, it allows inheritance oI all kinds oI classes including Throwable classes. For example. II you are building a web site where users log in and buy stuII, you don't want your system to break down iI a user has an expired credit card. You probably don't want to ignore that either. public class CreditCardExpiredException extends Exception...} This special exception is thrown manually since it is user-deIined. public void login () throws CreditCardExpiredException, UserDoeNotExistException iI ( CreditCardExpired() ) throw new CreditCardExpiredException() ; } iI ( FileNotFound() ) throw new UserDoeNotExistException() ; } } public void Initializer () try login() ; } catch ( CreditCardExpiredException ex ) /** todo Handle this exception */ } catch ( UserDoeNotExistException ex ) /** todo Handle this exception */ } } Where CreditCardExpiredException and UserDoeNotExistException are user deIined Exceptions (extend the class Exception) What is instantiation? !ava rogrammlng LdlL caLegorles SAP Certification @ NIITNIIT.com/SAPeducation Enrol in 4 weeks SAP Program. Build yourself a better Career. Ads lmprove nswer Answer ln programmlng Lerms lL ls when you creaLe an lnsLance of a varlable
lnsLanLlaLlon ls dlfferenL LhaL declaraLlon Lhough ln many cases Lhey happen aL Lhe same Llme
lor example lnLeger l
ls a declaraLlon Lelllng us LhaL l ls a Lype of Cb[ecL known as lnLeger l new lnLeger()
ls an lnsLanLlaLlon where Lhe varlable l (who should have prevlously been eclared) now has a speclflc lnsLance of lL 1haL ls Lhere ls a sLrucLure creaLed ln memory LhaL ls asslgned Lo l lnLeger l new lnLeger()
ls a eclaraLlon and lnsLanLlaLlon wrapped all LogeLher
8ead more hLLp//wlklanswerscom/C/JhaL_ls_lnsLanLlaLlon#lxzz1SvLmuuu usergeneraLed conLenL reporL abuse
What is public static void main in java? !ava rogrammlng LdlL caLegorles ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads lmprove nswer Answer the method oI an class that can is triggered when starting a Java application e.g. by running the command: "java MyProgram" Answer Public is an Access SpeciIier,static is a keyword which illustrates that method shared along all the classes.void illustrates that this method will not have any return type.main is the method which string has an argument.
8ead more hLLp//wlklanswerscom/C/JhaL_ls_publlc_sLaLlc_vold_maln_ln_[ava#lxzz1SvkvCwM What is an unhandled exception? n: Internet, Java Programming |Edit categories| Technology evelopmentwww.microsoft.com/office365 Work Together In Real Time On ocs, Spreadsheets and More. Learn How. Ads Improve Answer: An unhandled exception is an Exception that is thrown by execution but is never caught by the program, which results in a nasty Exception Stack. This could be avoided by catching the exception in a try-catch statement, but it is not always appropriate to catch every possible exception. Sometimes the exception is the result oI the client making a mistake rather than something that occurred where it is thrown, thereIore the client should be inIormed oI the exception. But most oI the time it is user Iriendly to not propagate exceptions.
Read more: http://wiki.answers.com/Q/Whatisanunhandledexception#ixzz1PSvNIEaJ What is the DiIIerence between java.io.BuIIeredWriter and java.io.FileWriter? n: Computer Programming, Java Programming |Edit categories| SAP Certification at NIITNIIT.com/SAP Enhance Your SAP Understanding with Our SAP Training Modules. Enroll! Ads Improve Answer: A FileWriter is used to send output to a Iile. A BuIIeredWriter uses an output buIIer to help increase perIormance when writing to a Iile or sending inIormation over a network.
These two classes are oIten used in conjunction with each other: BuIIeredWriter out new BuIIeredWriter(new FileWriter("myFile.txt"));
Read more: http://wiki.answers.com/Q/WhatistheDiIIerencebetweenjava.io.BuIIeredWriterandjava.i o.FileWriter#ixzz1PSvPlm33 What is instance? !ava rogrammlng CompuLer Sclence LdlL caLegorles SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Ads lmprove nswer Answer An individual object oI a certain class. While a class is just the type deIinition, an actual usage oI a class is called "instance". Each instance oI a class can have diIIerent values Ior its instance variables
8ead more hLLp//wlklanswerscom/C/JhaL_ls_lnsLance#lxzz1Sv8scrJ Which operators can be overloaded in java and which operators cannot be overloaded? !ava rogrammlng LdlL caLegorles Technology Communicationwww.microsoft.com/office365 Work Together In Real Time On ocs, Spreadsheets and More. Learn How. Ads lmprove nswer Answer Java does not support opperator overloading, so the answer to your question is: none.
8ead more hLLp//wlklanswerscom/C/Jhlch_operaLors_can_be_overloaded_ln_[ava_and_whlch_operaLors_cann oL_be_overloaded#lxzz1SvvCZ8x What is hashing in Java? n: Java Programming |Edit categories| ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads Improve Answer: Creating a Integer out oI an object is called hashing. Hashing is commonly used in HashTable, HashMaps and HashSet. For instance you have Alex John Peter Hashing on each value would generate something like 123455 Alex 123344 John 123987 Peter when put in hashtable or hashset would be quicker to Iind each piece oI inIormation. There are many algorithms available with java to get the hash oI an object.
What is the Iinal keyword in Java? n: Java Programming |Edit categories| ava Programming CoursesNIIT.com/ava-Training NIIT Offers ava Courses. Fast Track Career Programs. Enroll Now! Ads Improve Answer: The Iinal keyword precedes a declared constant which aIter Instantiation cannot be modiIied.
Examples.
Iinal double PI 3.14;
PI 1234; // does not compile
//or
Iinal double ONE;
ONE 1; // Instantiated ONE 2; // does not compile
---------------------------------------- Iinal keyword can also apply to a method or a class. When applied to a method - it means the method cannot be over-ridden. Specially useIul when a method assigns a state that should not be changed in the classes that inherit it, and should use it as it is (not change the method behaviour). When applied to a class it means that the class cannot be instantiated. A common use is Ior a class that only allows static methods as entry points or static Iinal constants - to be accessed without a class instance.
A good example is Java's: public Iinal class Math extends Object
How do you make struts action class thread saIe? !ava rogrammlng LdlL caLegorles Sap Vacancywww.IBM.com/SAP-obs 3+ Years of Experience esired. Limited Openings Available. Hurry! Ads lmprove nswer Answer |yDeoca|Iar|ab|e 1he mosL lmporLanL prlnclple LhaL alds ln Lhreadsafe codlng ls Lo use only local varlables noL lnsLance varlables ln your cLlon class Local varlables are creaLed on a sLack LhaL ls asslgned (by your !vM) Lo each requesL Lhread so Lhere ls no need Lo worry abouL sharlng Lhem n cLlon can be facLored lnLo several local meLhods so long as all varlables needed are passed as meLhod parameLers 1hls assures Lhread safeLy as Lhe !vM handles such varlables lnLernally uslng Lhe call sLack whlch ls assoclaLed wlLh a slngle 1hread Coervekeource s a general rule allocaLlng scarce resources and keeplng Lhem across requesLs from Lhe same user (ln Lhe users sesslon) can cause scalablllLy problems lor example lf your appllcaLlon uses !8C and you allocaLe a separaLe !8C connecLlon for every user you are probably golng Lo run ln some scalablllLy lssues when your slLe suddenly shows up on SlashdoL ?ou should sLrlve Lo use pools and release resources (such as daLabase connecLlons) prlor Lo forwardlng Answers.com ~ Wiki Answers ~ Categories ~ Technology ~ Computers ~ Computer Programming ~ Java Programming ~ Java runtime error - NoClassDeIFoundError -- how to remove this error in java programming? user-generated content: report abuse
Java runtime error - NoClassDeIFoundError -- how to remove this error in java programming? n: Java Programming |Edit categories| ava eveloperwww.IBM.com/eveloper-obs Web, 2EE & .Net Experts Required. oin Us, Make the World Work Better Ads Improve Answer: This error means that there was a call to a nonexistent class, but this was not caught by the compiler since the class existed when the Iile was compiled but was removed beIore running the .class Iile. To Iix this problem try restoring any Iiles you deleted to the SAME directory as your .class Iile.
This error can also be Iixed by changing the Java classpath to point to the locations oI your Iiles. The -cp command line option should help. Note: There are comments associated with this question. See the discussion page to add to the conversation.
Read more: http://wiki.answers.com/Q/Javaruntimeerror-NoClassDeIFoundError-- howtoremovethiserrorinjavaprogramming#ixzz1PSvqsKie How do you synchronize java? !ava rogrammlng LdlL caLegorles Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads lmprove nswer Answer
Synchronizaion is the process by which only one Thread can access an object at a time,until and unless thread releases it's lock no other thread can acess the object. there are two Iorms oI syncronization 2ethod and state2ent.
to make a method synchronized just add the keyword synchronized to the signature ie: public synchronized void increment() c; }
to create syncrhonized statements are like this:
synchronized(this) lastName name; nameCount; }
note: constructors can not be syncronized
8ead more hLLp//wlklanswerscom/C/Pow_do_you_synchronlze_[ava#lxzz1Svxl6mc What is the diIIerence between a class and an object? !ava rogrammlng C Sharp C++ rogrammlng LdlL caLegorles ava eveloperwww.IBM.com/eveloper-obs Web, 2EE & .Net Experts Required. oin Us, Make the World Work Better Ads lmprove nswer Answer An object is an instance oI a class. (in the same way that GarIield is an instance oI a cat)
Such that, iI class is: class MyClass public: int x; };
Then an object would be: int main()
MyClass myobject; }
8ead more hLLp//wlklanswerscom/C/JhaL_ls_Lhe_dlfference_beLween_a_class_and_an_ob[ecL#lxzz1Sw0L8xd Why should an object hide its data? n: Java Programming |Edit categories| ownload Google Chromewww.Google.com/Chrome Searching is fast and easy with Google's web browser. Ads Improve Answer: Answer As my AP Computer Science teacher eloquently said: "You can't let strangers touch your private parts"
ThereIore, iI data was not hidden, a client class can modiIy all the variables(given that it is not a final constant) by simply calling: className.variableName newWrongData; By using special methods to access the variables, the class can change its internal implementation, without breaking compatibility with other classes that are already using it
What is Java heap? n: Java Programming |Edit categories| ownload Google Chromewww.Google.com/Chrome Searching is fast and easy with Google's web browser. Ads Improve Answer: When you hear "heap space" you can just think oI a chunk oI memory allocated Ior your program. Heap space in Java is used Ior storing all Objects and all shared (global) primitive types. Every new object created using new operator or via any other method e.g. ReIlection is created in Java Heap. Java heap is Iurther divided into three generation Ior ease oI garbage collection in java they are
1) Young Generation 2) Tenured Generation 3) PERM Generation.
young Generation is Iurther divided into Eden space and Survivor1 and Survivor 2
Read more: http://wiki.answers.com/Q/WhatisJavaheap#ixzz1PSwA8WMJ What is the diIIerence between String and String BuIIer? n: Java Programming |Edit categories| ava obswww.IBM.com/Software-obs Expert Testers & evelopers Needed. Search by Location & Experience! Ads Improve Answer: In Java, String is a class that represents an immutable string, that is a sequence oI characters that can never change. Any modiIication to the String will have to create a new String object. A StringBuIIer (and in Java 1.5 and up, a StringBuilder) is a mutable string object that can be modiIied at runtime.
The advantages oI using Strings are that the String is generally lighter and Iaster to use where the String isn't going to change. When building a long String oI text by making changes to one object over time, you should use a StringBuilder or StringBuIIer (in Java 1.4 or when synchronization is important).
SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program!
Read more: http://wiki.answers.com/Q/WhatisthediIIerencebetweenStringandStringBuIIer#ixzz1P SwBjbBY How do you create java thread? !ava rogrammlng LdlL caLegorles Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads lmprove nswer Answer Thread can be created in two ways either by extending Thread or implementing runnable interIace
Examples: public class A extends Thread } public class A implements Runnable } By using both the methods we can create a Java Thread. The disadvantage oI extending the Thread class is that, you cannot extend the Ieatures oI any other class. II we extend the Thread class we cannot extend any other class whose Ieatures we may require in this class. So it is usually advisable to implement the Runnable InterIace so that we can extend the required Ieatures and at the same time use the Thread Iunctionality.
8ead more hLLp//wlklanswerscom/C/Pow_do_you_creaLe_[ava_Lhread#lxzz1Swlll7o Write a java program to sort a list oI numbers?
Read more: http://wiki.answers.com/Q/WriteajavaprogramtosortalistoInumbers#ixzz1PSwKTXV d The simplest would be to put the numbers into an int|| (integer array) and pass that to java.util.Arrays.sort(int||) (a static method), which will sort the array in ascending numerical order. Use a Iloat|| or double|| iI you need to sort non-whole numbers. You can also use the Collections.sort(List) method to sort the List directly. Or the Collections.sort(List, Comparator) iI you wish to speciIy your own sorting criteria.
Read more: http://wiki.answers.com/Q/WriteajavaprogramtosortalistoInumbers#ixzz1PSwMX8B 1 Advantages and disadvantages oI abstract class? !ava rogrammlng LdlL caLegorles Liferay Training Programwww.cignex.com/services/training CIGNEX - Liferay Platinum Partner offering Liferay training globally Ads lmprove nswer Answer An Abstract class is a way to organize inheritance, sometimes it makes no since to implement every method in a class (i.e. a predator class), it may implement some to pass to its children but some methods cannot be implemented without knowing what the class will do (i.e. eat() in a Tiger class). ThereIore, abstract classes are templates Ior Iuture speciIic classes. A disadvantage is that abstract classes cannot be instantiated, but most oI the time it is logical not to create a object oI an abstract class. heloooooo
8ead more hLLp//wlklanswerscom/C/dvanLages_and_dlsadvanLages_of_absLracL_class#lxzz1Swuqb6 What are the Ieatures oI daemon thread in java? n: Java Programming |Edit categories| Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads Improve Answer: Any Java thread can be a dae2on thread. Daemon threads are service providers Ior other threads running in the same process as the daemon thread. For example, the HotJava browser uses up to Iour daemon threads named "Image Fetcher" to Ietch images Irom the Iile system or network Ior any thread that needs one. The run() method Ior a daemon thread is typically an inIinite loop that waits Ior a service request. When the only remaining threads in a process are daemon threads, the interpreter exits. This makes sense because when only daemon threads remain, there is no other thread Ior which a daemon thread can provide a service. To speciIy that a thread is a daemon thread, call the setDaemon() method with the argument true. To determine iI a thread is a daemon thread, use the accessor method isDaemon(). Note: There are comments associated with this question. See the discussion page to add to the conversation.
Read more: http://wiki.answers.com/Q/WhataretheIeaturesoIdaemonthreadinjava#ixzz1PSxHRrNI What is an initialization statement? n: Java Programming |Edit categories| Liferay Training Programwww.cignex.com/services/training CIGNEX - Liferay Platinum Partner offering Liferay training globally Ads Improve Answer: When a declared variable receives a value to hold.
i.e.
int lalalala;
lalalala 0; //initialization oI lalalala
Read more: http://wiki.answers.com/Q/Whatisaninitializationstatement#ixzz1PSxKIbz2 What are the concepts oI object oriented programming? n: Java Programming, VBNET |Edit categories| Gaming, Hacking, LobbiesiHack360.com Modding, Hacking, Tutorials, 10th Lobbies, tags, News, Games. Ads Improve Answer: They are the Iollowing: Class DeIines the abstract characteristics oI a thing (object), including the thing's characteristics (its attributes, fields or properties) and the thing's behaviors (the things it can do, or methods, operations or features). One might say that a class is a -:eprint or factory that describes the nature oI something. For example, the class Dog would consist oI traits shared by all dogs, such as breed and Iur color (characteristics), and the ability to bark and sit (behaviors). Classes provide modularity and structure in an object-oriented computer program. A class should typically be recognizable to a non-programmer Iamiliar with the problem domain, meaning that the characteristics oI the class should make sense in context. Also, the code Ior a class should be relatively selI-contained (generally using encapsulation). Collectively, the properties and methods deIined by a class are called members. Object A pattern (exemplar) oI a class. The class oI Dog deIines all possible dogs by listing the characteristics and behaviors they can have; the object Lassie is one particular dog, with particular versions oI the characteristics. A Dog has Iur; Lassie has brown-and-white Iur. Instance One can have an instance oI a class or a particular object. The instance is the actual object created at runtime. In programmer jargon, the Lassie object is an instance oI the Dog class. The set oI values oI the attributes oI a particular object is called its state. The object consists oI state and the behaviour that's deIined in the object's class. Method An object's abilities. In language, methods (sometimes reIerred to as "Iunctions") are verbs. Lassie, being a Dog, has the ability to bark. So bark() is one oI Lassie's methods. She may have other methods as well, Ior example sit() or eat() or walk() or save_timmy(). Within the program, using a method usually aIIects only one particular object; all Dogs can bark, but you need only one particular dog to do the barking. Message passing "The process by which an object sends data to another object or asks the other object to invoke a method." Also known to some programming languages as interIacing. For example, the object called Breeder may tell the Lassie object to sit by passing a "sit" message which invokes Lassie's "sit" method. The syntax varies between languages, Ior example: Lassie sit, in Objective-C. In Java, code-level message passing corresponds to "method calling". Some dynamic languages use double-dispatch or multi- dispatch to Iind and pass messages. Inheritance "Subclasses" are more specialized versions oI a class, which inherit attributes and behaviors Irom their parent classes, and can introduce their own. For example, the class Dog might have sub-classes called Collie, Chihuahua, and GoldenRetriever. In this case, Lassie would be an instance oI the Collie subclass. Suppose the Dog class deIines a method called bark() and a property called furColor. Each oI its sub-classes (Collie, Chihuahua, and GoldenRetriever) will inherit these members, meaning that the programmer only needs to write the code Ior them once. Each subclass can alter its inherited traits. For example, the Collie class might speciIy that the deIault furColor Ior a collie is brown-and-white. The Chihuahua subclass might speciIy that the bark() method produces a high pitch by deIault. Subclasses can also add new members. The Chihuahua subclass could add a method called tremble(). So an individual chihuahua instance would use a high-pitched bark() Irom the Chihuahua subclass, which in turn inherited the usual bark() Irom Dog. The chihuahua object would also have the tremble() method, but Lassie would not, because she is a Collie, not a Chihuahua. In Iact, inheritance is an "a... is a" relationship between classes, while instantiation is an "is a" relationship between an object and a class: a Collie is a Dog ("a... is a"), -:t Lassie is a Collie ("is a"). Th:s, the o-ect na2ed Lassie has the 2ethods fro2 -oth casses Collie and Dog. :tipe inheritance is inheritance fro2 2ore than one ancestor cass, neither of these ancestors -eing an ancestor of the other. For exa2pe, independent casses co:d define Dogs and Cats, and a Chimera o-ect co:d -e created fro2 these two which inherits a the (2:tipe) -ehavior of cats and dogs. This is not aways s:pported, as it can -e hard -oth to i2pe2ent and to :se we. -straction -straction is si2pifying co2pex reaity -y 2odeing casses appropriate to the pro-e2, and working at the 2ost appropriate eve of inheritance for a given aspect of the pro-e2. For exa2pe, Lassie the Dog 2ay -e treated as a Dog 2:ch of the ti2e, a Collie when necessary to access Collie-specific attri-:tes or -ehaviors, and as an Animal (perhaps the parent cass of Dog) when co:nting Ti22ys pets. -straction is aso achieved thro:gh Co2position. For exa2pe, a cass Car wo:d -e 2ade :p of an Engine, Gear-ox, Steering o-ects, and 2any 2ore co2ponents. To -:id the Car cass, one does not need to know how the different co2ponents work internay, -:t ony how to interface with the2, i.e., send 2essages to the2, receive 2essages fro2 the2, and perhaps 2ake the different o-ects co2posing the cass interact with each other. Encaps:ation Encaps:ation conceas the f:nctiona detais of a cass fro2 o-ects that send 2essages to it. For exa2pe, the Dog cass has a bark() 2ethod. The code for the bark() 2ethod defines exacty how a -ark happens (e.g., -y inhale() and then exhale(), at a partic:ar pitch and vo:2e). Ti22y, Lassies friend, however, does not need to know exacty how she -arks. Encaps:ation is achieved -y specifying which casses 2ay :se the 2e2-ers of an o-ect. The res:t is that each o-ect exposes to any cass a certain interface - those 2e2-ers accessi-e to that cass. The reason for encaps:ation is to prevent cients of an interface fro2 depending on those parts of the i2pe2entation that are ikey to change in f:t:re, there-y aowing those changes to -e 2ade 2ore easiy, that is, witho:t changes to cients. For exa2pe, an interface can ens:re that p:ppies can ony -e added to an o-ect of the cass Dog -y code in that cass. e2-ers are often specified as public, protected or private, deter2ining whether they are avaia-e to a casses, s:--casses or ony the defining cass. So2e ang:ages go f:rther. Java :ses the default access 2odifier to restrict access aso to casses in the sa2e package, C# and JB.NET reserve so2e 2e2-ers to casses in the sa2e asse2-y :sing keywords internal (C#) or Friend (JB.NET), and Eiffe and C aow one to specify which casses 2ay access any 2e2-er. !oy2orphis2 !oy2orphis2 aows the progra22er to treat derived cass 2e2-ers :st ike their parent cass 2e2-ers. ore precisey, !oy2orphis2 in o-ect-oriented progra22ing is the a-iity of o-ects -eonging to different data types to respond to 2ethod cas of 2ethods of the sa2e na2e, each one according to an appropriate type-specific -ehavior. One 2ethod, or an operator s:ch as , -, or *, can -e a-stracty appied in 2any different sit:ations. If a Dog is co22anded to speak(), this 2ay eicit a bark(). However, if a Pig is co22anded to speak(), this 2ay eicit an oink(). They -oth inherit speak() fro2 Animal, -:t their derived cass 2ethods override the 2ethods of the parent cass, this is Overriding !oy2orphis2. Overoading !oy2orphis2 is the :se of one 2ethod signat:re, or one operator s:ch as "", to perfor2 severa different f:nctions depending on the i2pe2entation. The "" operator, for exa2pe, 2ay -e :sed to perfor2 integer addition, foat addition, ist concatenation, or string concatenation. ny two s:-casses of Number, s:ch as Integer and Double, are expected to add together propery in an OO! ang:age. The ang:age 2:st therefore overoad the addition operator, "", to work this way. This heps i2prove code reada-iity. How this is i2pe2ented varies fro2 ang:age to ang:age, -:t 2ost OO! ang:ages s:pport at east so2e eve of overoading poy2orphis2. any OO! ang:ages aso s:pport !ara2etric !oy2orphis2, where code is written witho:t 2ention of any specific type and th:s can -e :sed transparenty with any n:2-er of new types. !ointers are an exa2pe of a si2pe poy2orphic ro:tine that can -e :sed with 2any different types of o-ects. Deco:ping Deco:ping aows for the separation of o-ect interactions fro2 casses and inheritance into distinct ayers of a-straction. co22on :se of deco:ping is to poy2orphicay deco:pe the encaps:ation, which is the practice of :sing re:sa-e code to prevent discrete code 2od:es fro2 interacting with each other. However, in practice deco:ping often invoves trade-offs with regard to which patterns of change to favor. The science of 2eas:ring these trade-offs in respect to act:a change in an o-ective way is sti in its infancy. Not a of the a-ove concepts are to -e fo:nd in a o-ect-oriented progra22ing ang:ages, and so o-ect-oriented progra22ing that :ses casses is caed so2eti2es cass--ased progra22ing. In partic:ar, prototype--ased progra22ing does not typicay :se casses. s a res:t, a significanty different yet anaogo:s ter2inoogy is :sed to define the concepts of o-ect and instance.
Read more: http://wiki.answers.com/Q/WhataretheconceptsoIobjectorientedprogramming#ixzz1PSx OvNII Answers.com ~ Wiki Answers ~ Categories ~ Technology ~ Computers ~ Computer Programming ~ Java Programming ~ Write a Java program to convert six digit number into words? user-generated content: report abuse
Write a Java program to convert six digit number into words? n: Java Programming |Edit categories| Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads Improve Answer: /** * Note: this should work Ior all 0 num 1,000,000,000 * return a String representing the English-word value oI num */ public static Iinal String numberToWord(Iinal int num) // special case to simpliIy later on iI (num 0) return "zero"; }
// use StringBuilder Ior eIIicient modiIications StringBuilder numWord new StringBuilder();
int n num;
// append with selective recursion Ior all our cases iI (n ~ 1000000) numWord.append(numberToWord(n / 1000000)); numWord.append(' '); numWord.append(n1000000); numWord.append(' '); n 1000000; }
iI (n ~ 1000) numWord.append(numberToWord(n / 1000)); numWord.append(' '); numWord.append(n1000); numWord.append(' '); n 1000; } iI (n ~ 100) numWord.append(n19|n / 100|); numWord.append(' '); numWord.append(n100); numWord.append(' '); n 100;
} iI (n ~ 20) numWord.append(n2090|(n / 10) - 1|); numWord.append(' '); n 10; } iI (n ~ 10) numWord.append(n1019|n - 10|); } iI (n 10) numWord.append(n19|n|); }
return numWord.toString().trim(); }
Read more: http://wiki.answers.com/Q/WriteaJavaprogramtoconvertsixdigitnumberintowords#ix zz1PSxTCmxH Source code Ior client server connection program by socket programming in Java? n: Computer Networking, Java Programming |Edit categories| SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Ads Improve Answer: Apologies in advance Ior the lengthy example. Below is an example oI a client-server pair sending each other a message. This shows Java's TCP implementation oI Server/ServerSocket classes because they're very simple and easy to use.
A Iew things to be aware oI when testing these classes out: 1. You can start one oI these classes with TCPServer.start() or TCPClient.start(). 2. Always start the TCPServer class beIore the TCPClient class. II you don't, it's possible that the TCPClient will throw an exception and exit quietly, while the TCPServer class waits Iorever Ior a client to connect. 3. The current setup will connect on 127.0.0.1, which is your own computer. This will work even iI you have no network/internet connection. II you wish to connect to a remote computer, change the TCPClient.HOST value to the IP address (or hostname) oI the computer that will be running the server. // Code to run both parts oI the program Irom the same computer. // (This will make Ior some jumbled output) class Main public static void main(String|| args) new TCPServer().start(); new TCPClient().start(); } }
class TCPClient extends Thread // Connection properties private static Iinal String HOST "127.0.0.1"; private static Iinal int PORT 56565;
public void run() // Socket class used Ior TCP connections Socket sock null;
try // Connect our socket to the server. sock new Socket(HOST, PORT);
// Use a BuIIeredReader to read data Irom the server. input new BuIIeredReader(new InputStreamReader(sock.getInputStream()));
// Use a BuIIeredWriter to send data to the server. output new BuIIeredWriter(new OutputStreamWriter(sock.getOutputStream()));
// Send some data to the server. String toServer "Are you there, Server?"; System.out.println("ToServer: " toServer); output.write(toServer); output.newLine(); output.Ilush();
// Wait Ior a response Irom the server and display it. String IromServer input.readLine(); System.out.println("FromServer: " IromServer);
} catch (Iinal IOException ex) } Iinally // Do our best to ensure a clean close procedure. // Closing the socket will also close input and output. try iI (sock ! null) sock.close(); } } catch (Iinal IOException ex) } } } }
class TCPServer extends Thread // Connection properties private static Iinal int PORT 56565;
public void run() // ServerSocket class used to accept TCP connections ServerSocket server null; Socket sock null;
try // Create our server on the given port. server new ServerSocket(PORT);
// Wait Ior a client to connect to us. sock server.accept();
// Use a BuIIeredReader to read data Irom the client. input new BuIIeredReader(new InputStreamReader(sock.getInputStream()));
// Use a BuIIeredWriter to send data to the client. output new BuIIeredWriter(new OutputStreamWriter(sock.getOutputStream()));
// Wait Ior the client to talk to us. String IromClient input.readLine(); System.out.println("FromClient: " IromClient);
// Send them a response. String toClient "Yes, I'm here, Client."; System.out.println("ToClient: " toClient); output.write(toClient); output.newLine(); output.Ilush();
} catch (Iinal IOException ex) } Iinally // Do our best to ensure a clean close procedure. // Closing the socket will also close input and output. try iI (sock ! null) sock.close(); } } catch (Iinal IOException ex) }
// Close the server socket, as well. try iI (server ! null) server.close(); } } catch (Iinal IOException ex) } } } }
Read more: http://wiki.answers.com/Q/SourcecodeIorclientserverconnectionprogrambysocketpro gramminginJava#ixzz1PSxYIEOu What is the diIIerence between method overriding and method overloading in Java? n: Java Programming |Edit categories| SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Ads Improve Answer: Method overriding is when a child class redeIines the same method as a parent class, with the same parameters. For example, the standard Java class java.util.LinkedHashSet extends java.util.HashSet. The method add() is overridden in LinkedHashSet. II you have a variable that is oI type HashSet, and you call its add() method, it will call the appropriate implementation oI add(), based on whether it is a HashSet or a LinkedHashSet. This is called polymorphism.
Method overloading is deIining several methods in the same class, that accept diIIerent numbers and types oI parameters. In this case, the actual method called is decided at compile-time, based on the number and types oI arguments. For instance, the method System.out.println() is overloaded, so that you can pass ints as well as Strings, and it will call a diIIerent version oI the method.
Overriding is an example oI run time polymorphism. The JVM does not know which version oI method would be called until the type oI reIerence will be passed to the reIerence variable. It is also called Dynamic Method Dispatch. Overloading is an example oI compile time polymorphism.
Read more: http://wiki.answers.com/Q/WhatisthediIIerencebetweenmethodoverridingandmethodo verloadinginJava#ixzz1PSxbFAOg How prevent inheritance in java without Iinal? !ava rogrammlng LdlL caLegorles Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads lmprove nswer Answer Make the constructor private. Uhm, how would you make a instance oI this class then? Why don't you want inheritance? I don't understand! Answer: You can create the class without the public declaration. In such a case the access Ior that class would be deIault and hence you cannot extend that speciIic class outside its package. Still you can extend this class within its package.
The purpose oI having the Iinal keyword is to ensure that the class is not inherited. doing it without Iinal is like touching your nose around your head when you can do it straightaway... Note: There are comments associated with this question. See the discussion page to add to the conversation.
8ead more hLLp//wlklanswerscom/C/Pow_prevenL_lnherlLance_ln_[ava_wlLhouL_flnal#lxzz1Sxd1n Why path and class-path in java? n: Java Programming |Edit categories| Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads Improve Answer: 1))What is the diIIerence between "path" and "classpath"? Ans:: We keep all "executable Iiles"(like .exe Iiles) and "batch Iiles"(like .bat) in path variable. And we keep all jar Iiles and class Iiles in classpath variables. So path is set according to the .exe Iiles & .bat Iiles And classpath is set according to the .jar Iiles & .class Iiles.
Operating system tries to Iind .exe and .bat Iiles in path and JVM tries to Iind all classes in classpath.
Read more: http://wiki.answers.com/Q/Whypathandclass-pathinjava#ixzz1PSxgC8sv DiIIerence between a Ior loop and while loop? n: Windows, Java Programming, C Programming |Edit categories| View 20 Lacs + Tenderswww.TenderTiger.com India's National Tender Portal Call 09824051600 / 09374530073 Ads Improve Answer: One Iirst basic rule is that you should use the for loop when the number oI iterations is known. For instance: O The loop iterates over the elements oI a collection. O The loop iterates over a range oI values which is known in advance at execution time. O The object provides a way to iterate over its elements with a for statements (e.g Iiles).
The while loop is the more general one because its loop condition is more Ilexible and can be more complicated than that oI a for loop. The condition oI a for loop is always the same and implicit in the construction. A for loop stops iI there are no more elements in the collection to treat. For simple traversals or iterations over index ranges it is a good advice to use the for statement because it handles the iteration variable Ior you, so it is more secure than while where you have to handle the end oI the iteration and the change oI the iteration variable by yourselI. The while loop can take every boolean expression as condition and permits thereIore more complex end conditions. It is also the better choice iI the iteration variable does not change evently by the same step or iI there are more than one iteration variable. Even iI you can handle more than one iteration variable in a for statement, the collections Irom which to choose the values must have the same number oI elements.
Note: In C 'Ior' and 'while' can be easily replaced by each other:
while (exp) stmt Ior (;exp;) stmt
Ior (exp1;exp2;exp3) stmt exp1; while (exp2) stmt exp3}}
Read more: http://wiki.answers.com/Q/DiIIerencebetweenaIorloopandwhileloop#ixzz1PSxj6PTU What is diIIerence between jvm and interpreter? n: Java Programming, Education, The DiIIerence Between |Edit categories| O This content needs improvement: Under Review by MRA (Category Supervisor) Improve Answer: Java interpreter implements the jvm.java interpreter convert the byte code(.class Iiles) into sytem code(operating system understandale code) than it get execute.interpreter in java is name as "java". c:~java classname when u put this statement ur class Iile gets convert into machine code(system code) & gets execute.
In my view the above answer is not completely Iull Iilled because JVM contain interpreter as well as JIT (Just In Time) compiler . Interpreter use is already given by Ashvini . Then the use oI JIT is it convert the byte code(.class Iiles) into system code(operating system understandale code) than it get execute and converted code is Ietch into some memory iI same statement is repeated then directly already converted code is given as result. Note: There are comments associated with this question. See the discussion page to add to the conversat
Read more: http://wiki.answers.com/Q/WhatisdiIIerencebetweenjvmandinterpreter#ixzz1PSxl8egQ How do you call an external Iile in java? n: Java Programming |Edit categories| Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads Improve Answer: The class I Iind useIul is the FileReader class in java.io. It allows you to read an external Iile in your program.
For instance,
Consider a file input.txt:
Hello How are you? 1 2 3 4 5
You can access it by:
FileReader read new FileReader("input.txt"); // pass the Iile name as a String
//now the read is the Iile //can scan Irom the Iile using Scanner
Scanner scan new Scanner(read); System.out.println( scan.nextLine()); // prints Hello System.out.println( scan.nextLine()); // prints How are you? while(scan.hasNextInt()) System.out.print(scan.nextInt() " "); // prints 1 2 3 4 5
Read more: http://wiki.answers.com/Q/HowdoyoucallanexternalIileinjava#ixzz1PSxoM9sQ JAVA program Ior sorting the elements in the array? n: Computer Programming, Java Programming |Edit categories| Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads Improve Answer: II you are really lazy, like me, I just use what Java 5.0 has advailable.
Just call Arrays.sort();
put your data structure as the parameter, it is a void method.
Oracle ba Supportwww.IBM.com/Oracle-obs Showcase Your Expertise at IBM. oin Us, Be an Innovator.
Read more: http://wiki.answers.com/Q/JAVAprogramIorsortingtheelementsinthearray#ixzz1PSxrD Bu6 Garbagecolllecter in java? n: Java Programming |Edit categories| Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads Improve Answer: Yes, Java programming language has a Garbage collector Ior unused memory. and the best part about it is that it does it automatically.
The Garbage Collector is built into the Java Virtual Machine, and will do automatic garbage collection Ior you. II you chose to compile your Java code down to native code (via a Java- ~native code compiler), then NO garbage collection is done Ior you.
Read more: http://wiki.answers.com/Q/Garbagecolllecterinjava#ixzz1PSyJxD3D How multiple inheritance is achieved in Java? n: Java Programming |Edit categories| Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads Improve Answer: Java supports a limited Iorm a multiple inheritance by allowing a class to inherit Irom one other class and an unlimited number oI interIaces. A Iull multiple inheritance capability was leIt out oI the Java language to keep it simple and avoid abuse.
A skeletal example Ior multiple implementation:
interIace Swimmer
public void swim(); }
interIace Runner
public void run(); }
interIace Biker
public void bike(); }
class Athlete
... }
class TriathalonAthlete extends Athlete implements Swimmer, Runner, Biker
public void swim(); public void run(); public void bike(); }
Read more: http://wiki.answers.com/Q/HowmultipleinheritanceisachievedinJava#ixzz1PSyM7uxF What should you make static in Java? !ava rogrammlng LdlL caLegorles Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads lmprove nswer Static keyword signals something that is shared among all objects oI the same class: i.e. a variable that all objects oI the class can reIerence to, or method that all objects oI the class can access. tatic Variables
Usually, class constants are made static since it is the same in all objects oI the same class thus it saves space not having to have variables Ior the same data Ior each class. But usually private instances should not be made static since it creates some strange situations, i.e. iI you modiIy the data oI one object, the data oI the other object oI the same class is also changed. tatic Metbods
Statics methods are common in main classes, in Iact the main method itselI is static, meaning it does not need a object to call it. The helper methods in a main class is usually static, since main classes are non-instantiable.
8ead more hLLp//wlklanswerscom/C/JhaL_should_you_make_sLaLlc_ln_!ava#lxzz1Sy1xcL8 DiIIerence between JAVA class and bean? !ava rogrammlng 1he lfference 8eLween LdlL caLegorles Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads lmprove nswer Answer Mostly the java class and the Bean class are similar one. In Bean class we have getter and setter methods. Its just a naming convention. Regards Santhosh rao
In http://Iorums.sun.com/thread.jspa?threadID526214 Java Beans Iollow the Bean conventions:
(1) DeIault, no-arg ctor, (2) Serializable, (3) getX()/setX() or isX()/setX() naming convention Ior read/write access to private data member X, (4) Can use java.bean.PropertyChangeEvent to notiIy interested parties when values change. (5) Can use java.bean.PropertyChangeListener to register Ior notiIication when a particular property changes.
"Normal" Java classes aren't required to Iollow any oI these conventions.
There's a great |urlhttp://java.sun.com/docs/books/tutorial/javabeans/|tutorial|/url| on Java Beans Irom Sun.
For gamers. By gamers.www.game4u.com iscover an all new range of game accessories from Razer ava Programmerwww.IBM.com/Software-obs Expert Testers & evelopers Needed. Search by Location & Experience
8ead more hLLp//wlklanswerscom/C/lfference_beLween_!v_class_and_bean#lxzz1SyeJ6cJ DiIIerentiate between multiprocessing and multiprogramming? n: Java Programming, Operating Systems, The DiIIerence Between |Edit categories| Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads Improve Answer: Multiprocessing means the computer can do multiple processes parallel oI each other (at the same time) with no perIormance degradation. Multiprogramming is an application that can be used to interIace with diIIerent programming languages (java, C, etc)
For gamers. By gamers.www.game4u.com iscover an all new range of game accessories from Razer Learn Ethical Hackingwww.innobuzz.in Information Security and Ethical Hacking Training Program- Bengaluru ava Programmerwww.IBM.com/Software-obs Expert Testers & evelopers Needed. Search by Location & Experience! Ads
Read more: http://wiki.answers.com/Q/DiIIerentiatebetweenmultiprocessingandmultiprogramming#ixzz 1PSyWjpu4 DiIIerence between JAVA class and bean? !ava rogrammlng 1he lfference 8eLween LdlL caLegorles Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads lmprove nswer Answer Mostly the java class and the Bean class are similar one. In Bean class we have getter and setter methods. Its just a naming convention. Regards Santhosh rao
In http://Iorums.sun.com/thread.jspa?threadID526214 Java Beans Iollow the Bean conventions:
(1) DeIault, no-arg ctor, (2) Serializable, (3) getX()/setX() or isX()/setX() naming convention Ior read/write access to private data member X, (4) Can use java.bean.PropertyChangeEvent to notiIy interested parties when values change. (5) Can use java.bean.PropertyChangeListener to register Ior notiIication when a particular property changes.
"Normal" Java classes aren't required to Iollow any oI these conventions.
There's a great |urlhttp://java.sun.com/docs/books/tutorial/javabeans/|tutorial|/url| on Java Beans Irom Sun.
For gamers. By gamers.www.game4u.com iscover an all new range of game accessories from Razer ava Programmerwww.IBM.com/Software-obs Expert Testers & evelopers Needed. Search by Location & Experience
8ead more hLLp//wlklanswerscom/C/lfference_beLween_!v_class_and_bean#lxzz1SyeJ6cJ What is diIIerence between class and object in java? !ava rogrammlng CompuLer Sclence LdlL caLegorles Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads lmprove nswer Answer A class is basically a deIinition, and contains the object's code. An object is an instance oI a class. For instance, there is one java.lang.String class, but you can instantiate any number oI distinct java.lang.String objects (instances). While a class deIines the instance variables than an object has, the instantiated object itselI actually contains those variables. So to put it simply: An object is an instance oI a class.
Graphic esign in 12 mthswww.Arena-Multimedia.com Learn reamweaver,Illustrator & CR oin University iploma at Arena! Film Editing Coursewww.dafilmschool.com
8ead more hLLp//wlklanswerscom/C/JhaL_ls_dlfference_beLween_class_and_ob[ecL_ln_[ava#lxzz1SyzxcvS How do you convert an int to char in java? n: Java Programming |Edit categories| Sql Programmingwww.IBM.com/Oracle-obs Showcase Your Expertise at IBM. oin Us, Be an Innovator. Ads Improve Answer: It depends on what you mean by "convert an int to char".
II you simply want to cast the value in the int, you can cast it using Java's typecast notation: int i 97; // 97 is 'a' in ASCII char c (char) i; // c is now 'a'
II you mean transIorming the integer 1 into the character '1', you can do it like this: iI (i ~ 0 && i 9) char c Character.IorDigit(i, 10); .... }
20 lakh IT jobswww.Aptech-Education.com Get a global career through Aptech Work in the IT field of your choice SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Softech Campuswww.softechcampus.com A Un
Read more: http://wiki.answers.com/Q/Howdoyouconvertaninttocharinjava#ixzz1PSz8Qcm9 What is Iilewriter? n: Java Programming |Edit categories| For gamers. By gamers.www.game4u.com iscover an all new range of game accessories from Razer Ads Improve Answer: It is a class that creates a Iile and allows you to write into the Iile. A better class Ior Java I/O is the PrintWriter class, which is more natural since its methods correspond to System.out, i.e. Iile.print("blah blah blah"), rather than remembering Iile.write();
Read more: http://wiki.answers.com/Q/WhatisIilewriter#ixzz1PSzTFaEI Why is the JVM platIorm dependent? n: Java Programming, Computer Science |Edit categories| Construction Platformwww.xiongyudl.com China Professional Manufacturer of Suspended Access Platforms Ads Improve Answer: DiIIerent OS will executes theire some own type oI Iiles take an example Ior windows os, in this every Iile will be installed by .exe Iile and unix it will be another Iile executes so jvm depends on OS
Read more: http://wiki.answers.com/Q/WhyistheJVMplatIormdependent#ixzz1PSzWE7Do DiIIerence between JAVA class and bean? !ava rogrammlng 1he lfference 8eLween LdlL caLegorles Pune Chinchwad etkingwww.netcomeducation.co.in Hardware & Networking,Ccna,Mcitp Mobile Apl.eveloper,Android,ava, Ads lmprove nswer Answer Mostly the java class and the Bean class are similar one. In Bean class we have getter and setter methods. Its just a naming convention. Regards Santhosh rao
In http://Iorums.sun.com/thread.jspa?threadID526214 Java Beans Iollow the Bean conventions:
(1) DeIault, no-arg ctor, (2) Serializable, (3) getX()/setX() or isX()/setX() naming convention Ior read/write access to private data member X, (4) Can use java.bean.PropertyChangeEvent to notiIy interested parties when values change. (5) Can use java.bean.PropertyChangeListener to register Ior notiIication when a particular property changes.
"Normal" Java classes aren't required to Iollow any oI these conventions.
There's a great |urlhttp://java.sun.com/docs/books/tutorial/javabeans/|tutorial|/url| on Java Beans Irom Sun.
For gamers. By gamers.www.game4u.com iscover an all new range of game accessories from Razer
8ead more hLLp//wlklanswerscom/C/lfference_beLween_!v_class_and_bean#lxzz1Szdk What is multithreading? n: Computer Programming, Java Programming, Operating Systems
Operating systems, both proprietary and open-source, include those produced by MicrosoIt, Linux, and Apple Mac |Edit categories| SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Ads Improve Answer: The ability oI an operating system to execute diIIerent parts oI a program, called threads, simultaneously. The programmer must careIully design the program in such a way that all the threads can run at the same time without interIering with each other. Answer Taking a computer job/process, and coding it so the job utilitzes multiple resources Ior execution, this Iinishing Iaster. examples: machine has 16 cpu's. the job uses all 16 cpu's to process
Read more: http://wiki.answers.com/Q/Whatismultithreading#ixzz1PSzjAFDJ Answer: Since an interIace has no implemented methods, there is nothing to extend, since you would simply get empty method headings you can't make a class by extending an interIace. An interIace must be implemented, by Iilling in the method bodies. An interIace is a tool to deIine common characteristics between classes, i.e. how they act. For instance, an interIace might be used to deIine a window, a simple generic window: it opens, closes, breaks.
InterIaces are useIul to the client since you don't need to know the inner workings oI the class to use it, Ior instance, as long as you know the data structure you are working with is a List, you don't need to know whether it is an ArrayList or LinkedList.
CFA Institutewww.cfainstitute.org/India Contribute Towards Fair and Efficient Global Financial Markets. SAP Certification at NIITNIIT.com/SAP Leading Provider of SAP Training In Asia. Enrol in 4 weeks SAP Program! Educational Franchisewww.TheScholarsHub.com Get Our Tuition Center Franchisee. An Investment Of Only 5-10 Lakhs! Ads
Read more: http://wiki.answers.com/Q/WhyinjavainterIaceisusedIormutipleinheritancenotbyext ends#ixzz1PSzmAyXH When to use multiple and multilevel inheritance? CompuLer SofLware and ppllcaLlons !ava rogrammlng LdlL caLegorles Accenture SAP QM Careerswww.accenture.com/SAP Opportunities for SAP QM Experts. Learn More & Apply Online Now. Ads lmprove nswer Answer Multiple inheritance is likely to be most useIul when you can separate the characteristics oI objects into orthogonal sets, in which the characteristics oI one set do not depend on the characteristics oI other sets. II you can deIine a class to represent each set oI characteristics, you can use multiple inheritance to build complex classes with diIIerent combinations oI characteristics. We gave a glimpse oI how to create such a design by starting to segregate characteristics oI Ilying and ground vehicles, and then noting that certain vehicles, like such as aircraIt, can combine both sets oI characteristics. Another approach that can be useIul Ior various applications is to create one or more base superclasses, which deIine common characteristics oI subclasses, and a number oI mix-in classes, each oI which adds a set oI orthogonal characteristics. A mix-in class is like an addition, such as chocolate chips or nuts, that might be mixed into an ice-cream base. Another way to think about this approach is to imagine the base class as a noun and the mix-in classes as adjectives that modiIy or specialize the noun. You can then construct concrete subclasses by using multiple inheritance. For each concrete subclass, one or more mix-in classes typically precede a single base class in the list oI superclasses. EXAMPLE : deIine abstract class vehicle-storage~ (physical-object~) slot identiIier :: string~, required- init-keyword: id:; ... end class vehicle-storage~; deIine abstract class vehicle~ (physical- object~) slot vehicle-id :: string~, required-init-keyword: id:; ... end class vehicle~; deIine class airport~ (physical-object~) slot name :: string~, init-keyword: name:; ... end class airport~; deIine class airline~ (object~) slot name :: string~, required-init-keyword: name:; ... end class airline~; Multiple inheritance provides several advantages in solving the name problem: 1. We localize in a single class the characteristic oI having a name. 2. Subclasses can still customize aspects oI the name attribute, such as what that attribute's initial value is, and whether or not it is required. 3. We can give a subclass a name attribute without redeIining any oI its superclasses. 4. The only subclasses that have a name attribute are those Ior which that is appropriate. MULTI LEVEL INHERITANCE: I believe this i got this code Irom others it may helps u: just experiment on it: OK, here's the code n check it: 1195c1195 IND(s); s uqname() "var actual" Iqname() ";\n\n"; --- ~ IND(s); s objreIuqname() " actual" Iqname() ";\n\n"; 1245c1245 IND(s); s "void setproxy(" lcproxyuqname() --- ~ IND(s); s wrapproxyuqname() "(" lcproxyuqname() 1247d1246 IND(s); s wrapproxyuqname() "() }\n"; 1860d1858 IND(s); s "CORBA::release(p);\n"; 2146c2144 IND(s); s "CORBA::release(actual" Iqname() ");\n"; --- ~ IND(s); s "CORBA::release(actual" Iqname() ");"; 2237c2235,2260 ",r,key,keysize,proIiles,release)\n"; --- ~ ",r,key,keysize,proIiles,release)"; ~ ~ int ni,j; ~ ASTInterIace **intItable; ~ ni ninherits(); ~ intItable inherits(); ~ Ior (j0; j ni; j) ~ ~ o2beinterIace * intI o2beinterIace::narrowIromdecl(intItable|j|); ~ char* intIname (char*)intI- ~unambiguouswrapproxyname(this); ~ iI (o2beglobal::mIlag()) ~ // MSVC 4.2,5.0} cannot deal with a call to a virtual member ~ // oI a base class using the member Iunction's Iully/partially ~ // scoped name. Have to use the alias Ior the base class in the ~ // global scope to reIer to the virtual member Iunction instead. ~ iI (strcmp(intIname,intI-~wrapproxyuqname()) ! 0) ~ intIname new char|strlen(intI-~scopename()) ~ strlen(intI- ~wrapproxyuqname())1|; ~ strcpy(intIname,intI-~scopename()); ~ strcat(intIname,intI- ~wrapproxyuqname()); ~ } ~ } ~ s ", " intIname "(proxy)"; ~ } ~ } ~ s "\n"; 2242c2265,2304 IND(s); s "setproxy(proxy);\n"; --- ~ IND(s); s "orig" Iqname() " proxy;\n"; ~ IND(s); s "actual" Iqname() " " Iqname() ~ "::duplicate(proxy);\n"; ~ DECINDENTLEVEL(); ~ IND(s); s "}\n\n"; ~ ~ IND(s); s wrapproxyIqname() "::" wrapproxyuqname() ~ "(" lcproxyIqname() " *proxy)"; ~ ~ int ni,j; ~ ASTInterIace **intItable; ~ ni ninherits(); ~ intItable inherits(); ~ char *sep " : "; ~ Ior (j0; j ni; j) ~ ~ o2beinterIace * intI o2beinterIace::narrowIromdecl(intItable|j|); ~ char* intIname (char*)intI- ~unambiguouswrapproxyname(this); ~ iI (o2beglobal::mIlag()) ~ // MSVC 4.2,5.0} cannot deal with a call to a virtual member ~ // oI a base class using the member Iunction's Iully/partially ~ // scoped name. Have to use the alias Ior the base class in the ~ // global scope to reIer to the virtual member Iunction instead. ~ iI (strcmp(intIname,intI-~wrapproxyuqname()) ! 0) ~ intIname new char|strlen(intI-~scopename()) ~ strlen(intI- ~wrapproxyuqname())1|; ~ strcpy(intIname,intI-~scopename()); ~ strcat(intIname,intI- ~wrapproxyuqname()); ~ } ~ } ~ s sep intIname "(proxy)"; ~ sep ", "; ~ } ~ } ~ s "\n"; ~ IND(s); s "\n"; ~ INCINDENTLEVEL(); ~ IND(s); s "orig" Iqname() " proxy;\n"; ~ IND(s); s "actual" Iqname() " " Iqname() ~ "::duplicate(proxy);\n"; 2253a2316,2317 ~ IND(s); s "CORBA::release(orig" Iqname() ");\n"; ~ IND(s); s "CORBA::release(actual" Iqname() ");\n"; 2286a2351 ~ IND(s); s "CORBA::release(actual" Iqname() ");\n"; 2338a2404 ~ IND(s); s "CORBA::release(actual" Iqname() ");\n"; 2367,2403d2432 // setproxy: IND(s); s "void\n"; IND(s); s wrapproxyIqname() "::setproxy(" lcproxyIqname() " *proxy)\n"; IND(s); s "\n"; INCINDENTLEVEL(); IND(s); s "orig" Iqname() " proxy;\n"; IND(s); s "actual" Iqname() " " Iqname() "::duplicate(proxy);\n"; int ni,j; ASTInterIace **intItable; ni ninherits(); intItable inherits(); Ior (j0; j ni; j) o2beinterIace * intI o2beinterIace::narrowIromdecl(intItable|j|); char* intIname (char*)intI- ~unambiguouswrapproxyname(this); iI (o2beglobal::mIlag()) // MSVC 4.2,5.0} cannot deal with a call to a virtual member // oI a base class using the member Iunction's Iully/partially // scoped name. Have to use the alias Ior the base class in the // global scope to reIer to the virtual member Iunction instead. iI (strcmp(intIname,intI-~wrapproxyuqname()) ! 0) intIname new char|strlen(intI-~scopename()) strlen(intI- ~wrapproxyuqname())1|; strcpy(intIname,intI-~scopename()); strcat(intIname,intI- ~wrapproxyuqname()); } } IND(s); s intIname "::setproxy(proxy);\n"; } } DECINDENTLEVEL(); IND(s); s "}\n"; Cheers, Annapurna
SAP Certification @ NIITNIIT.com/SAPeducation Enrol in 4 weeks SAP Program. Build yourself a better Career. 1yr Management Programprogram.niitimperia.com/PGPM With ual Specialisation. Certified by IMT Ghaziabad. 1+yr Exp Apply ! Sap jobs for Fresherswww.MonsterIndia.com 100s of obs Listed Sign up Now Ads
8ead more hLLp//wlklanswerscom/C/Jhen_Lo_use_mulLlple_and_mulLllevel_lnherlLance#lxzz1Szr04oM hy in java interIace is used Ior mutiple inheritance not by extends? n: Java Programming |Edit categories| SAP Mm Employmentwww.accenture.com/SAP Opportunities for SAP MM Experts. View obs & Submit Your CV Now. Ads Improve Answer: Since an interIace has no implemented methods, there is nothing to extend, since you would simply get empty method headings you can't make a class by extending an interIace. An interIace must be implemented, by Iilling in the method bodies. An interIace is a tool to deIine common characteristics between classes, i.e. how they act. For instance, an interIace might be used to deIine a window, a simple generic window: it opens, closes, breaks.
InterIaces are useIul to the client since you don't need to know the inner workings oI the class to use it, Ior instance, as long as you know the data structure you are working with is a List, you don't need to know whether it is an ArrayList or LinkedList.
Read more: http://wiki.answers.com/Q/WhyinjavainterIaceisusedIormutipleinheritancenotbyext ends#ixzz1PSzuht9T When to use multiple and multilevel inheritance? CompuLer SofLware and ppllcaLlons !ava rogrammlng LdlL caLegorles Accenture SAP QM Careerswww.accenture.com/SAP Opportunities for SAP QM Experts. Learn More & Apply Online Now. Ads lmprove nswer Answer Multiple inheritance is likely to be most useIul when you can separate the characteristics oI objects into orthogonal sets, in which the characteristics oI one set do not depend on the characteristics oI other sets. II you can deIine a class to represent each set oI characteristics, you can use multiple inheritance to build complex classes with diIIerent combinations oI characteristics. We gave a glimpse oI how to create such a design by starting to segregate characteristics oI Ilying and ground vehicles, and then noting that certain vehicles, like such as aircraIt, can combine both sets oI characteristics. Another approach that can be useIul Ior various applications is to create one or more base superclasses, which deIine common characteristics oI subclasses, and a number oI mix-in classes, each oI which adds a set oI orthogonal characteristics. A mix-in class is like an addition, such as chocolate chips or nuts, that might be mixed into an ice-cream base. Another way to think about this approach is to imagine the base class as a noun and the mix-in classes as adjectives that modiIy or specialize the noun. You can then construct concrete subclasses by using multiple inheritance. For each concrete subclass, one or more mix-in classes typically precede a single base class in the list oI superclasses. EXAMPLE : deIine abstract class vehicle-storage~ (physical-object~) slot identiIier :: string~, required- init-keyword: id:; ... end class vehicle-storage~; deIine abstract class vehicle~ (physical- object~) slot vehicle-id :: string~, required-init-keyword: id:; ... end class vehicle~; deIine class airport~ (physical-object~) slot name :: string~, init-keyword: name:; ... end class airport~; deIine class airline~ (object~) slot name :: string~, required-init-keyword: name:; ... end class airline~; Multiple inheritance provides several advantages in solving the name problem: 1. We localize in a single class the characteristic oI having a name. 2. Subclasses can still customize aspects oI the name attribute, such as what that attribute's initial value is, and whether or not it is required. 3. We can give a subclass a name attribute without redeIining any oI its superclasses. 4. The only subclasses that have a name attribute are those Ior which that is appropriate. MULTI LEVEL INHERITANCE: I believe this i got this code Irom others it may helps u: just experiment on it: OK, here's the code n check it: 1195c1195 IND(s); s uqname() "var actual" Iqname() ";\n\n"; --- ~ IND(s); s objreIuqname() " actual" Iqname() ";\n\n"; 1245c1245 IND(s); s "void setproxy(" lcproxyuqname() --- ~ IND(s); s wrapproxyuqname() "(" lcproxyuqname() 1247d1246 IND(s); s wrapproxyuqname() "() }\n"; 1860d1858 IND(s); s "CORBA::release(p);\n"; 2146c2144 IND(s); s "CORBA::release(actual" Iqname() ");\n"; --- ~ IND(s); s "CORBA::release(actual" Iqname() ");"; 2237c2235,2260 ",r,key,keysize,proIiles,release)\n"; --- ~ ",r,key,keysize,proIiles,release)"; ~ ~ int ni,j; ~ ASTInterIace **intItable; ~ ni ninherits(); ~ intItable inherits(); ~ Ior (j0; j ni; j) ~ ~ o2beinterIace * intI o2beinterIace::narrowIromdecl(intItable|j|); ~ char* intIname (char*)intI- ~unambiguouswrapproxyname(this); ~ iI (o2beglobal::mIlag()) ~ // MSVC 4.2,5.0} cannot deal with a call to a virtual member ~ // oI a base class using the member Iunction's Iully/partially ~ // scoped name. Have to use the alias Ior the base class in the ~ // global scope to reIer to the virtual member Iunction instead. ~ iI (strcmp(intIname,intI-~wrapproxyuqname()) ! 0) ~ intIname new char|strlen(intI-~scopename()) ~ strlen(intI- ~wrapproxyuqname())1|; ~ strcpy(intIname,intI-~scopename()); ~ strcat(intIname,intI- ~wrapproxyuqname()); ~ } ~ } ~ s ", " intIname "(proxy)"; ~ } ~ } ~ s "\n"; 2242c2265,2304 IND(s); s "setproxy(proxy);\n"; --- ~ IND(s); s "orig" Iqname() " proxy;\n"; ~ IND(s); s "actual" Iqname() " " Iqname() ~ "::duplicate(proxy);\n"; ~ DECINDENTLEVEL(); ~ IND(s); s "}\n\n"; ~ ~ IND(s); s wrapproxyIqname() "::" wrapproxyuqname() ~ "(" lcproxyIqname() " *proxy)"; ~ ~ int ni,j; ~ ASTInterIace **intItable; ~ ni ninherits(); ~ intItable inherits(); ~ char *sep " : "; ~ Ior (j0; j ni; j) ~ ~ o2beinterIace * intI o2beinterIace::narrowIromdecl(intItable|j|); ~ char* intIname (char*)intI- ~unambiguouswrapproxyname(this); ~ iI (o2beglobal::mIlag()) ~ // MSVC 4.2,5.0} cannot deal with a call to a virtual member ~ // oI a base class using the member Iunction's Iully/partially ~ // scoped name. Have to use the alias Ior the base class in the ~ // global scope to reIer to the virtual member Iunction instead. ~ iI (strcmp(intIname,intI-~wrapproxyuqname()) ! 0) ~ intIname new char|strlen(intI-~scopename()) ~ strlen(intI- ~wrapproxyuqname())1|; ~ strcpy(intIname,intI-~scopename()); ~ strcat(intIname,intI- ~wrapproxyuqname()); ~ } ~ } ~ s sep intIname "(proxy)"; ~ sep ", "; ~ } ~ } ~ s "\n"; ~ IND(s); s "\n"; ~ INCINDENTLEVEL(); ~ IND(s); s "orig" Iqname() " proxy;\n"; ~ IND(s); s "actual" Iqname() " " Iqname() ~ "::duplicate(proxy);\n"; 2253a2316,2317 ~ IND(s); s "CORBA::release(orig" Iqname() ");\n"; ~ IND(s); s "CORBA::release(actual" Iqname() ");\n"; 2286a2351 ~ IND(s); s "CORBA::release(actual" Iqname() ");\n"; 2338a2404 ~ IND(s); s "CORBA::release(actual" Iqname() ");\n"; 2367,2403d2432 // setproxy: IND(s); s "void\n"; IND(s); s wrapproxyIqname() "::setproxy(" lcproxyIqname() " *proxy)\n"; IND(s); s "\n"; INCINDENTLEVEL(); IND(s); s "orig" Iqname() " proxy;\n"; IND(s); s "actual" Iqname() " " Iqname() "::duplicate(proxy);\n"; int ni,j; ASTInterIace **intItable; ni ninherits(); intItable inherits(); Ior (j0; j ni; j) o2beinterIace * intI o2beinterIace::narrowIromdecl(intItable|j|); char* intIname (char*)intI- ~unambiguouswrapproxyname(this); iI (o2beglobal::mIlag()) // MSVC 4.2,5.0} cannot deal with a call to a virtual member // oI a base class using the member Iunction's Iully/partially // scoped name. Have to use the alias Ior the base class in the // global scope to reIer to the virtual member Iunction instead. iI (strcmp(intIname,intI-~wrapproxyuqname()) ! 0) intIname new char|strlen(intI-~scopename()) strlen(intI- ~wrapproxyuqname())1|; strcpy(intIname,intI-~scopename()); strcat(intIname,intI- ~wrapproxyuqname()); } } IND(s); s intIname "::setproxy(proxy);\n"; } } DECINDENTLEVEL(); IND(s); s "}\n"; Cheers, Annapurna
SAP Certification @ NIITNIIT.com/SAPeducation Enrol in 4 weeks SAP Program. Build yourself a better Career. 1yr Management Programprogram.niitimperia.com/PGPM With ual Specialisation. Certified by IMT Ghaziabad. 1+yr Exp Apply ! Sap jobs for Fresherswww.MonsterIndia.com 100s of obs Listed Sign up Now Ads
8ead more hLLp//wlklanswerscom/C/Jhen_Lo_use_mulLlple_and_mulLllevel_lnherlLance#lxzz1Szr04oM hy in java interIace is used Ior mutiple inheritance not by extends? n: Java Programming |Edit categories| SAP Mm Employmentwww.accenture.com/SAP Opportunities for SAP MM Experts. View obs & Submit Your CV Now. Ads Improve Answer: Since an interIace has no implemented methods, there is nothing to extend, since you would simply get empty method headings you can't make a class by extending an interIace. An interIace must be implemented, by Iilling in the method bodies. An interIace is a tool to deIine common characteristics between classes, i.e. how they act. For instance, an interIace might be used to deIine a window, a simple generic window: it opens, closes, breaks.
InterIaces are useIul to the client since you don't need to know the inner workings oI the class to use it, Ior instance, as long as you know the data structure you are working with is a List, you don't need to know whether it is an ArrayList or LinkedList.
Read more: http://wiki.answers.com/Q/WhyinjavainterIaceisusedIormutipleinheritancenotbyext ends#ixzz1PSzuht9T Why in java interIace is used Ior mutiple inheritance not by extends? n: Java Programming |Edit categories| SAP Mm Employmentwww.accenture.com/SAP Opportunities for SAP MM Experts. View obs & Submit Your CV Now. Ads Improve Answer: Since an interIace has no implemented methods, there is nothing to extend, since damnyou would simply get empty method headings you can't make a class by extending an interIace. An interIace must be implemented, by Iilling in the method bodies. An interIace is a tool to deIine common characteristics between classes, i.e. how they act. For instance, an interIace might be used to deIine a window, a simple generic window: it opens, closes, breaks.
InterIaces are useIul to the client since you don't need to know the inner workings oI the class to use it, Ior instance, as long as you know the data structure you are working with is a List, you don't need to know whether it is an ArrayList or LinkedList.
Read more: http://wiki.answers.com/Q/WhyinjavainterIaceisusedIormutipleinheritancenotbyext ends#ixzz1PT05AmoA Why in java interIace is used Ior mutiple inheritance not by extends? n: Java Programming |Edit categories| SAP Mm Employmentwww.accenture.com/SAP Opportunities for SAP MM Experts. View obs & Submit Your CV Now. Ads Improve Answer: Since an interIace has no implemented methods, there is nothing to extend, since you would simply get empty method headings you can't make a class by extending an interIace. An interIace must be implemented, by Iilling in the method bodies. An interIace is a tool to deIine common characteristics between classes, i.e. how they act. For instance, an interIace might be used to deIine a window, a simple generic window: it opens, closes, breaks.
InterIaces are useIul to the client since you don't need to know the inner workings oI the class to use it, Ior instance, as long as you know the data structure you are working with is a List, you don't need to know whether it is an ArrayList or LinkedList.
In Java what is hybrid inheritance? Pybrld lnherlLance ls a compromlse beLween sLrlcLly slngle lnherlLance and Lrue mulLlple lnherlLance
Slngle lnherlLance means LhaL one class may have exacLly one parenL class Jhlle Lhls ls nlce Lo have lL makes creaLlng complex sysLems an even more complex process
MulLlple lnherlLance means LhaL one class may have any number of parenL classes 1hls ls one of Lhe feaLures of C++ LhaL Lhe deslgners of !ava wanLed Lo do away wlLh 1rue mulLlple lnherlLance can lnLroduce amblgulLy when Lwo dlfferenL parenL classes each has a funcLlon deflned wlLh Lhe same name and number/Lype of argumenLs 1he program has no ldea of knowlng whlch one ls supposed Lo be called and how Lhe cholce ls made ls ofLen a nondeLermlnlsLlc lmplemenLaLlonspeclflc rule
1he deslgners of !ava wanLed someLhlng more flexlble Lhan slngle lnherlLance buL noL as compllcaLed and problemaLlc as mulLlple lnherlLance So Lhey came up wlLh whaL ls known as hybrld lnherlLance 1hls ls Lhe sysLem whlch dlfferenLlaLes beLween a class and an lnLerface
class ln !ava lnherlLs from one oLher class (lf no class ls speclfled lL lnherlLs from class Cb[ecL) 1haL same class may also lnherlL from any number of lnLerfaces 1he reason for Lhls ls Lo remove any amblgulLy for dupllcaLe meLhod deflnlLlons Slnce each class may only lnherlL from one oLher class lL ls synLacLlcally lmposslble Lo have mulLlple deflnlLlons for Lhe same meLhod
LeLs look aL an example
// 1hls class has one meLhod ln lL whlch adds an Cb[ecL Lo an rrayLlsL class publlc rrayLlsLCb[ecL llsL publlc vold add(Cb[ecL o) llsLadd(o)
// 1hls lnLerface ls ldenLlcal Lo lnLerface 8 lnLerface C publlc vold add(Cb[ecL o)
class exLends lmplemenLs 8 C
1hls empLy class avolds any klnd of meLhod deflnlLlon colllslon even Lhough each of Lhe Lhree classes and lnLerfaces lL lnherlLs from deflne Lhe same meLhod lL can do Lhls because only one lmplemenLaLlon of a meLhod can ever be passed down Lo a chlld class
Slnce meLhod lmplemenLaLlons are noL allowed ln lnLerfaces you are guaranLeed Lo encounLer one of Lwo scenarlos 1 1he lnLerface meLhod hasnL been lmplemenLed and your class needs Lo do so 1he lnLerface meLhod has already been lmplemenLed ln your classs superclass and so your class does noL need Lo do so (Lhough you can overrlde lL lf you wanL Lo) noLe LhaL Lhere ls no comblnaLlon of classes or lnLerfaces whlch wlll presenL a case of havlng mulLlple lmplemenLaLlons of Lhe same meLhod
8ead more hLLp//wlklanswerscom/C/ln_!ava_whaL_ls_hybrld_lnherlLance#lxzz1?Ps4huL