Can a java program run on the browser?
No it can't, this is the difference between Java and JavaScript (which don't have that much to do with one-another) Java is more like C in that it can on the web-server or on any computer really, but it is not like JavaScript which runs inside a sandbox inside the browser.
When object is created and destroyed in java?
in java object is created as soon a class comes into picture......and distroyed ehwn exit that class.............
(object) it is running instance .........
submitted by- shreyas joshi..
What are the unique advantages of object oriented programming paradigm?
a. OOP provides a clear modular structure for programs which makes it good for defining abstract datatypes where implementation details are hidden and the unit has a clearly defined interface.
b. OOP makes it easy to maintain and modify existing code as new objects can be created with small differences to existing ones.
c. OOP provides a good framework for code libraries where supplied software components can be easily adapted and modified by the programmer. This is particularly useful for developing graphical user interfaces.
Why you are calling java programming language java?
One code to run them all!
All you have to do is write one program and it runs on all 3 of the supported OS.
Cell phones are a little different since they can't support everything PC can. They have their own version of java.
Normally if you have to rewrite bits of your program to get it working on both windows and Mac.
What is Objectives Oriented Evaluation Approach to program evaluation?
Objectives Oriented Evaluation Approach is the means by which the worth or merit of a program is assessed based on the extent to which the objectives or purposes of the program are being achieved.
Assume the question was for C#, not C.
":" is syntax to extend a type. If the type extended from is another class, they form a class hierarchy and the "inheritance" is established:
For example:
class Base {}
class Derived : Base {}
Derived extends Base, and thus inherits from Base.
What is the definition of a base-class constructor?
A base class constructor is simply a constructor that is declared within a base class. There is nothing particularly special about them since all constructors are only of relevence and applicable to the classes in which they are declared.
How do you empty a file using C programming?
That depends on the type of file and what you mean by "empty". Generally, fopen() called on an existing file, with the "w" option instead of the "a" option will truncate the file to zero length. To delete a file completely is a different process. Function truncate is your friend.
What is hyper text markup language and describe its role in implementation of java applets?
Short for HyperText Markup Language, the authoring language for creating documents on the world wide web.HTML defines the structure and layout of a Web document by using a variety of tags and attributes.
The correct structure for an HTML document starts with
(enter here what document is about) and ends with < All the information you'd like to include in your Web page fits in between the and tags.HTML is very important in describe of java applets and its implementation.
An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled browser to view a page that contains an applet, the applet's code is transferred to your system and executed by the browser's Java Virtual Machine (JVM).
What are the best ways to learn and understand Java and what books are good for this?
Best way to learn Java is start from basic.Get a clear picture about JVM and JRE.Even if you write a simple program,try to understand what happens behind your code.I suggest you to read more about java at http://allinalljava.blogspot.com. At first while writing your code attach java source behind ,due to that you can easily admire real scenario happen in it.
I suggest you try http://academicjava.com. It's a resource of many example programs with explanations and there's a very good tutorial.
"Head first JAVA" is the book I recommend but it's a question of what's best for you. Go to a good bookshop and browse what's available.
At first, i would like to tell you the BEST way to learn JAVA is just "Type Java programs n execute them". start with simple programs...
"Head first JAVA" - It is the one of the best book to learn Java.
If you want to understand Java's advantages elaborately , then u can refer this page too
http://www.artima.com/insidejvm/ed2/
Best way to learn java is think of something real-world that you understand well and can automate. Write something like an electronic recipe organizer. The best book? Do a google search for "Java, The Complete Reference, J2se" Good luck!
That is a good book. Also try "Java In A Nutshell" from O'Reiley books. It makes an excellent quick reference and is very straightforward.
Yes, these are great resources and adding one more resource to the list which i found helpful while starting with Java --> the tutorials from Sun. You can find them here http://java.sun.com/docs/books/tutorial/
Happy Learning : )
A sub class is paired up with its super class. These can also be called a child and parent class.
The subclass will inherit all of the variables and methods from its superclass. And one superclass can have multiple subclasses, but a subclass can only have one superclass.
Here's an example:
public class childName extends parentName {
...
}
This means that childName will inherit everything from its superclass, which is parentName.
The advantage of this inheritance is that you do not need to copy/paste lots of code for many similar subclasses, and if you want to change something you only need to make one change in the superclass.
Describe three advantages of Java programming language?
Java has many more than 3 characteristics, which can be labelled "advantages"; of course, most of the following are shared by several other languages.
What is the use of throws io exception in java?
an IOException is any unexpected problem the compiler encounters while attempting to run a program. Possible problems the compiler may encounter are attempting to read from a file that does not exist, write to a file which has an invalid name (a slash or a question mark in the title should do it), or attempting to read the next token in a file when there are no more tokens.
What is classNotFound Exception in java?
If you are getting this error message, it means you are trying to use a class that is not located in your JVM classpath. In order to resolve this error, you must find the .class or the .jar file that contains the class you need, and add it to your classpath.
Depending on the application, it might be as simple as changing your CLASSPATH environment variable. Here is a good article on the Java classpath:
http://en.wikipedia.org/wiki/Classpath_(Java)
Here is a good online utility to help you quickly find the right jar and download it. It will save you hours of searching through various blog posts on the internet trying to find out which jar contains which class file!
http://www.ClassNotFound.com/
Write a program which uses Command Line Arguments?
IN C++
#include <iostream> int main(int argc, char *argv[]) { using namespace std; cout << "There are " << argc << " arguments:" << endl; // Loop through each argument and print its number and value for (int nArg=0; nArg < argc; nArg++) cout << nArg << " " << argv[nArg] << endl; return 0; }
What is the need of package in java?
Packages are containers-for-classes used to keep the class namespace compartmentalized.
Using Package,
1. We can define classes inside a package that are notaccessible by the code outside that package.
2. We can define class members that are only accessible by code inside that package.
3. We can have a class stored in a package withoutconcern that it will collide with some other class (havin same name), stored else where.
Package is basically a collection of predefined or ready-made classes that can be used in your java program to make shorter as well as easier. Package- import java.lang.*; is always implicitly called when you write a java program.
What is standalone application?
It means that it is by itself - as opposed to being bundled with other applications for example.
Java program that prints prime numbers between 1 to n?
The easiest way is to use a prime sieve (google Sieve of Eratosthenes).
Here is pseudo-code for the algorithm.
- create a boolean array of size n
- for every true index 2 through n
- - keep the index as true, mark all multiples of the index as false.
So, for example, if n=10
start with 2, keep 2 true. Mark 4,6,8,10 as false.
next is 3, keep it true. mark 6,9 as false (6 was already false).
next is 4, it is false, skip it.
next is 5, keep it true. mark 10 as false (it was already false).
6 is false, skip it
7 is true, keep it true. the next multiple of 7 is greater than 10
8,9, 10 are all false.
you are done - the values marked true (1,2, 3,5,7) are your primes.
Which keyword is used to declare a class?
There is no keyword for it. You can use a variable of 1 class in another only id the other class is derived from the 1st class.
Although you can use the variable of an object of a class in another class using object.variable
Inheritence and its types in object oriented programmings?
There are only two types of inheritance in object oriented programming:
Single inheritance: where a class inherits directly from just one base class.
Multiple inheritance: where a class inherits directly from two or more base classes.
Multi-level inheritance is often thought of as being a separate type of inheritance, however inheritance relates to a derived class and those that it directly inherits from. If a base class is itself a derived class (an intermediate class), then its base class or classes are simply indirect base classes of the derivative. But in isolation, the intermediate class either uses single or multiple inheritance, even if its base class or classes are also intermediates.
Virtual inheritance is also thought of as being a separate type, however virtual inheritance doesn't change the relationship between classes within the hierarchy. the only difference virtual inheritance makes is that the virtual base class or classes are constructed by the most-derived class within the current hierarchy, rather than by their most direct descendants. In this way, only one instance of each virtual base exists in the hierarchy, rather than multiple instance as would normally exist. The actual inheritance is still single or multiple, however.
How and where is the Java programming language used?
The computer-programming language Java is used when a powerful object-oriented programming language that can execute on a variety of operating systems, with little or no alterations to the code, is needed. Java "applets" are ideal for distribution over the internet owing to the diversity of systems that support Java and the inherently small size of the applet download.
How do you use sub string in java?
Substring method creates smaller string form bigger string , every time a new string is created but original character array buffer is used. so even if original string is 1G in size and substring is just 1K memory held by substring is 1G because of backed array. this can cause memory leak and prevent original string from garbage collection even if there is no direct reference.
How can you use abstract classes instead of interfaces?
In most cases, you will want to use abstract classes IN ADDITION to interfaces.
You should use an abstract class in the following circumstance:
In practice, abstract classes are a good way to collect common code into one place, to make maintenance easier.
For instance, say you have a class and interface structure like this:
Class A
Interface X
Class B extends A implements X
Class C extends A implements X
Both B and C will have the all the methods declared in X; if the implementation of those methods is the same (or can be made the same), then X is a good candidate for changing to an abstract method:
Class A
Abstract Class X extends A
Class B extends X
Class C extends X
Thus, you have removed the code duplication that was happening when using interfaces.
Note that doing the above is NOT a good idea if any class which implement interface X cannot be made a subclass of the new abstract class X.
What is the purpose of the finally clause of a try-catch-finally statement?
The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught. It is usually used in places where we are connecting to a database so that, we can close the connection or perform any cleanup even if the query execution in the try block caused an exception