What is the first name before of the Java Programming?
The first name of the Java Programming was Oak. It then went by the game Green and finally Java from Java coffee.
Which is to be learnes first java or java script?
There's an old saying among programmers that Java is to JavaScript as ham is to hamster. The one you choose to learn first is more a preferential choice than one of the easier way to learn.
Java is not related to JavaScript.
Java is an object-oriented, compiled computer language used to build everything from televisions to advanced scientific equipment to operating systems. Java has a very large set of prebuilt functions, and is similar to C#.
JavaScript is also object-oriented, but the kind of object orientation is different than most every other object oriented language. JavaScript allows you to manipulate the elements of an HTML document, as well as do some basic server-side stuff. JavaScript has a much smaller area of concern than Java. JavaScript remains plaintext, and is not compiled. It also has no access outside the browser (if they haven't made a mistake in the browser.)
I would suggest you learn JavaScript if you have an ambition to work with the web. Java also has a footprint on the internet, but it's mostly server-side and much smaller.
If you want to go into Software Engineering, and are looking for a good language to start dealing with the complexities therein, than Java is a good choice. It's robust, widely available, and has a vibrant community.
Learning both wouldn't hurt you either, but it's important to understand that they are not related in any way, except for their names, and an ancient connection to Netscape.
When a language has the capability to produce new data type is also called?
New, compared to what? I guess you meant user-defined data-types, which exist in almost every modern programming language.
The primitive data types in Java are:
Checked and unchecked exceptions?
Unchecked exceptions : * represent defects in the program (bugs) - often invalid arguments passed to a non-private method. To quote from The Java Programming Language, by Gosling, Arnold, and Holmes : "Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time." * are subclasses of RuntimeException, and are usually implemented using IllegalArgumentException, NullPointerException, or IllegalStateException * a method is not obliged to establish a policy for the unchecked exceptions thrown by its implementation (and they almost always do not do so) Checked exceptions : * represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent files) * are subclasses of Exception * a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the stack, or handle it somehow) It is somewhat confusing, but note as well that RuntimeException (unchecked) is itself a subclass of Exception (checked).
What is the use of static in public static void main?
The static keyword signifies that the method belongs to the class and not any of its objects. Hence, the JVM does not have to create an object of that class before beginning execution. Imagine how the JVM would create an object and invokes its method even before the class execution starts. That is why the main method is static and is the starting point of any java application.
What is single inheritance explain with an example?
Single Inheritance
In "single inheritance," a common form of inheritance, classes have only one base class. Consider the relationship illustrated in the following figure. Simple Single-Inheritance Graph
Note the progression from general to specific in the figure. Another common attribute found in the design of most class hierarchies is that the derived class has a "kind of" relationship with the base class. In the figure, a Book is a kind of a PrintedDocument, and a PaperbackBook is a kind of a book.
One other item of note in the figure: Book is both a derived class (from PrintedDocument) and a base class (PaperbackBook is derived from Book). A skeletal declaration of such a class hierarchy is shown in the following example:
Copy Code // deriv_SingleInheritance.cpp // compile with: /LD class PrintedDocument {}; // Book is derived from PrintedDocument. class Book : public PrintedDocument {}; // PaperbackBook is derived from Book. class PaperbackBook : public Book {};
PrintedDocument is considered a "direct base" class to Book; it is an "indirect base" class to PaperbackBook. The difference is that a direct base class appears in the base list of a class declaration and an indirect base does not.
The base class from which each class is derived is declared before the declaration of the derived class. It is not sufficient to provide a forward-referencing declaration for a base class; it must be a complete declaration.
In the preceding example, the access specifier public is used. The meaning of public, protected, and private inheritance is described in Member-Access Control.
A class can serve as the base class for many specific classes, as illustrated in the following figure. Sample of Directed Acyclic Graph
In the diagram shown above, called a "directed acyclic graph" (or "DAG"), some of the classes are base classes for more than one derived class. However, the reverse is not true: there is only one direct base class for any given derived class. The graph in the figure depicts a "single inheritance" structure. Note:
Directed acyclic graphs are not unique to single inheritance. They are also used to depict multiple-inheritance graphs. This topic is covered in Multiple Inheritance.
In inheritance, the derived class contains the members of the base class plus any new members you add. As a result, a derived class can refer to members of the base class (unless those members are redefined in the derived class). The scope-resolution operator (::) can be used to refer to members of direct or indirect base classes when those members have been redefined in the derived class. Consider this example:
Copy Code
// deriv_SingleInheritance2.cpp // compile with: /EHsc /c #include
Note that the constructor for Book, (Book::Book), has access to the data member, Name. In a program, an object of type Book can be created and used as follows:
Copy Code
// Create a new object of type Book. This invokes the // constructor Book::Book. Book LibraryBook( "Programming Windows, 2nd Ed", 944 ); ... // Use PrintNameOf function inherited from class Document. LibraryBook.PrintNameOf();
As the preceding example demonstrates, class-member and inherited data and functions are used identically. If the implementation for class Book calls for a reimplementation of the PrintNameOf function, the function that belongs to the Document class can be called only by using the scope-resolution (::) operator:
Copy Code
// deriv_SingleInheritance3.cpp // compile with: /EHsc /LD #include
Pointers and references to derived classes can be implicitly converted to pointers and references to their base classes if there is an accessible, unambiguous base class. The following code demonstrates this concept using pointers (the same principle applies to references):
Copy Code
// deriv_SingleInheritance4.cpp // compile with: /W3 struct Document { char *Name; void PrintNameOf() {} }; class PaperbackBook : public Document {}; int main() { Document * DocLib[10]; // Library of ten documents. for (int i = 0 ; i < 10 ; i++) DocLib[i] = new Document; }
In the preceding example, different types are created. However, because these types are all derived from the Document class, there is an implicit conversion to Document *. As a result, DocLib is a "heterogeneous list" (a list in which not all objects are of the same type) containing different kinds of objects.
Because the Document class has a PrintNameOf function, it can print the name of each book in the library, although it may omit some of the information specific to the type of document (page count for Book, number of bytes for HelpFile, and so on). Note:
Forcing the base class to implement a function such as PrintNameOf is often not the best design. Virtual Functions offers other design alternatives.
By:- Deb
hjuki
What is thread based multitasking?
-> Difference between process based and thread based multitasking:
1) threads share the same address space where as process doesn't.
2) context switching between threads is usually less expensive than between processes.
3) cost of communication between threads is relatively low.
What are features of java for web applications?
The most important and powerful feature of java as a programming language is that it is platform independent. The term platform independent means that java doesn't need a specific vendor oriented platform to run. It can be run on any of the existing platforms and would produce the same output. Thus, whether I run java on windows, unix, Linux or Macintosh, i would get the same desired result. Contrast this with .net which can only be used with windows.So, java is the only option we are left with for developing web based application. This is because internet is a network of millions of computers having different types of hardware and software. So, we definitely need a platform independent, easy to understand language to develop web based applications which can be distributed over any network and yet produce same result. That is why java is used in web applications.
In fact, java is so powerful that it is now also being used to develop mobile applications like games.
Give the brief history of java with its archietecture and its features?
James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time. The language was initially called Oak after an oak tree that stood outside Gosling's office; it went by the name Green later, and was later renamed Java, from Java coffee, said to be consumed in large quantities by the language's creators. Gosling aimed to implement avirtual machine and a language that had a familiar C/C++ style of notation.
Sun Microsystems released the first public implementation as Java 1.0 in 1995. It promised "Write Once, Run Anywhere" (WORA), providing no-cost run-times on popularplatforms. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated the ability to run Java applets within web pages, and Java quickly became popular. With the advent of Java 2 (released initially as J2SE 1.2 in December 1998-1999), new versions had multiple configurations built for different types of platforms. For example, J2EE targeted enterprise applications and the greatly stripped-down version J2ME for mobile applications (Mobile Java). J2SE designated the Standard Edition. In 2006, for marketing purposes, Sun renamed new J2 versions as Java EE, Java ME, and Java SE, respectively.
In 1997, Sun Microsystems approached the ISO/IEC JTC1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process. Java remains a de factostandard, controlled through the Java Community Process. At one time, Sun made most of its Java implementations available without charge, despite their proprietary software status. Sun generated revenue from Java through the selling of licenses for specialized products such as the Java Enterprise System. Sun distinguishes between its Software Development Kit (SDK) and Runtime Environment (JRE) (a subset of the SDK); the primary distinction involves the JRE's lack of the compiler, utility programs, and header files.
On November 13, 2006, Sun released much of Java as free and open source software, (FOSS), under the terms of the GNU General Public License (GPL). On May 8, 2007, Sun finished the process, making all of Java's core code available under free software/open-source distribution terms, aside from a small portion of code to which Sun did not hold the copyright.
Sun's vice-president Rich Green said that Sun's ideal role with regards to Java was as an "evangelist." Following Oracle Corporation's acquisition of Sun Microsystems in 2009-2010, Oracle has described itself as the "steward of Java technology with a relentless commitment to fostering a community of participation and transparency". This did not hold Oracle, however, from filing a lawsuit against Google shortly after that for using Java inside the Android SDK (see Google section below). Java software runs on laptops to data centers, game consoles to scientific supercomputers. There are 930 million Java Runtime Environment downloads each year and 3 billion mobile phones run Java.[21] On April 2, 2010, James Gosling resigned from Oracle.
What operator is used to create and make new object in oop?
By default, operator new() allocates memory on the free store (the heap). The standard defines four global operators:
The global operator new() has three standard implementations defined in
The first implementation allocates size bytes on the free store and returns a generic pointer (void*) to the first byte of the allocation. If the allocation fails for any reason, a std::bad_alloc exception is thrown. This operator is therefore known as a throwing allocation.
The second is the same as the first but does not throw an exception. If the allocation fails for any reason, nullptr is returned instead. this is known as a nothrow allocation.
The third version is used when (raw) memory has already been allocated and simply returns the given ptr argument. The memory referred to by ptr need not be allocated on the heap. This version is known as placement.
In all three cases, the allocated memory is simply raw, uninitialised memory (similar to what we would expect when invoking the standard global malloc() function in C).
In addition, the standard also defines global operator new[]() (also in
These versions are used when we wish to allocate an array of objects and have similar behaviours to the "normal" global operators.
Note that all these operators are defined implicitly; we do not need to explicitly include the
In order to physically construct an object via global operator new (), the object's class must define a static member operator new (). Given that it would be tedious to do this for every class that we define, this is done implicitly for us. Thus when we invoke the following:
T* ptr = new T {args...};
T* ptr = new T[N] {args...};
we are actually invoking the following:
T* ptr = T::operator new (args...);
T* ptr = T::operator new[] (N, args...);
The (implicit) static member operator new() and operator new[]() are implementation-defined, but will generally be defined as follows:
T* T::operator new (args...) {
T* ptr = ::new (sizeof (T)); // invoke the global operator (may throw)
// initialise the memory from args...
return ptr;
}
T* T::operator new[] (std::size_t N, args...) {
T* ptr = ::new[] (N * sizeof (T)); // invoke the global operator (may throw)
// initialise the memory for each N from args...
return ptr;
}
Now we can see where the std::size_t argument passed to global operator new() actually comes from.
Given that T::operator new() is a member function, it can be overloaded on a class-by-class basis if we wish to provide our own memory management facility. We can also overload the global operator new(), however this is not recommended because there's no way of knowing how other classes we have no control over might be affected, particularly those which provide their own member operator new() overloads and which expect the default behaviour of the global operator new(). Overloading global operator new() is not for the feint-hearted, thus it is recommended you use a tried-and-tested library for global memory management rather than attempting to write your own from scratch.
EJB generally is used for the following reasons -
1. To extract the business logic from web tier and implement the buginess logic in ejb.
2. EJB can also run on different system. So for big application to reduce load buniness logic implementation code can be executed in different system.
3. Since to run the EJB, develop needs an EJB container. So these are following activities are managed by the EJB container -
i. To handle resouce polling. Basically EJB container create EJB instance and place in poll to ready when require it provides the instance.
ii. Transaction management using @ContainerBeabManaged annotation
iii. Threading
iv. concurency handleing
Thanks
aswini.de@gmail.com
How do you write a java package program for addition?
A number of well-tested open-source Matrix Java libraries are available. Best to find and use one that's been around for a while since most of the bugs have been worked out. If you need to write your own it's still worth-while to examine the APIs of those libraries first.
JAMA is a free Java library for basic linear algebra and matrix operations developed as a straightforward public-domain reference implementation by MathWorks and NIST.
Example of Use. The following simple example solves a 3x3 linear system Ax=b and computes the norm of the residual.
double[][] array = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}};
Matrix A = new Matrix(array);
Matrix b = Matrix.random(3,1);
Matrix x = A.solve(b);
Matrix Residual = A.times(x).minus(b);
double rnorm = Residual.normInf();
Is java fully platform independent?
Java is a platform independent language.After compiling the ".java" file ,that will be converting into the ".class" file,which is a byte code having the capability run on any OS.Basing on the concept byte code java achieving the platform independent,it leads to "Write once run anywhere".
Write a program in java programming language to print welcome to java programming?
public class welcome { public static void main (String args[]) {
System.out.println("Welcome to Java programming");
}
}
There are also many "Hello World" tutorials you can find elsewhere on the internet
What is Dynamic Initialization in java?
Java allows us to perform 'dynamic initialization' of variables too.
What this means is that you can initialize variables using expressions (as will be seen in the example).
In the program, we have a int variable 'root' which has an initial defined value of 10. We then create another variable 'square' of the same data-type, which will store the square of root.
//This program displays dynamic initialization in java
publicclassExample
{
publicstaticvoidmain(String args[])
{
introot=10; //root has a constant value assigned
intsquare=root*root; //notice that square has "root*root" assigned to it
//if u change the value of root,
//the value of square changes accordingly
//after each compilation
//display the values of square and root
System.out.println("Root= " +root + " Square= "+square);
}
}
Is it possible to define a java static method inside a main method?
Because, the main method is the starting point of the java program and if we need an object of that class even before the main can be invoked, it is not possible. Hence it is declared static so that the JVM Can acess the main method without having to instantiate that particular class
What are examples of Object Oriented programming language?
Machine code, assembly language and C are all non-object oriented programming languages. Fortran, COBOL, Pascal and BASIC were originally non-object oriented languages but there are now object-oriented variants of these languages. C++, C# and Java were all designed with object-oriented programming in mind from the outset.
Why constructor overloading is useful in java?
Overloading a constructor means typing in multiple versions of the constructor, each having a different argument list, like the following examples:
class Car {
Car() { }
Car(String s) { }
}
The preceding Car class has two overloaded constructors, one that takes a string, and one with no arguments. Because there's no code in the no-arg version, it's actually identical to the default constructor the compiler supplies, but remember-since there's already a constructor in this class (the one that takes a string), the compiler won't supply a default constructor. If you want a no-arg constructor to overload the with-args version you already have, you're going to have to type it yourself, just as in the Car example.
Overloading a constructor is typically used to provide alternate ways for clients to instantiate objects of your class. For example, if a client knows the Car name, they can pass that to a Car constructor that takes a string. But if they don't know the name, the client can call the no-arg constructor and that constructor can supply a default name.
No. void is not a data type.
It is mandatory for all java methods to return something and if it is not going to return anything, we have to mark the method with a "void" return type to let the JVM know that it must not expect anything from the method.
No.
In C++, you can overload both methods, and existing operators - although you can't invent new operators.
In Java, many things that might cause confusion were eliminated; one of these is operator overloading. However, you can still overload methods, and this is sometimes very useful.
Why java takes 4 byte of int while c has 2?
Java defined int as a 32-bit number because that is generally large enough to hold the information you need.
The size of an int in C may actually have either 16 or 32 bits, depending on the implementation. Basically, the specifications for any C implementation in UNIX must have 32-bit ints, while the ISO C standard only requires 16-bit ints. The stdint.h and limits.h files exist exactly because not all implementations are the same, and these files will define the min/max values of the integral types.