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.
What are the importance of program tracing?
I suppose you mean, tracing through your code.
Quite often, the program doesn't work exactly as expected; you may wish to see, step by step, what exactly your program does, to check at what point it works differently than what you had foreseen. Sooner or later, if you write more complicated programs, you will have no choice but to do this kind of follow-up.
I suppose you mean, tracing through your code.
Quite often, the program doesn't work exactly as expected; you may wish to see, step by step, what exactly your program does, to check at what point it works differently than what you had foreseen. Sooner or later, if you write more complicated programs, you will have no choice but to do this kind of follow-up.
I suppose you mean, tracing through your code.
Quite often, the program doesn't work exactly as expected; you may wish to see, step by step, what exactly your program does, to check at what point it works differently than what you had foreseen. Sooner or later, if you write more complicated programs, you will have no choice but to do this kind of follow-up.
I suppose you mean, tracing through your code.
Quite often, the program doesn't work exactly as expected; you may wish to see, step by step, what exactly your program does, to check at what point it works differently than what you had foreseen. Sooner or later, if you write more complicated programs, you will have no choice but to do this kind of follow-up.
Do compiled programs usually run faster because they are already in machine code?
No it is because compiled programs are scared so they run like stink.
Plus, uncompiled programs, ie. source programs, do not run at all... neither slowly nor fast.
How to clear dos screen in JAVA?
I am also finding you can use this: System.out.println("\033");
I have checked it in Eclipse. Please check it in any other compiler/ IDE.
Sorry Doesn't work with my Java 6
Output -
/033
/033 : Your slash is the wrong way around ("\033", not "/033").
What is a template for building objects?
A Template in OO system refers to a skeleton or a framework or base pattern based on which further development is taken up.
How does hibernate work in java?
Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database. Hibernate solves object-relational impedance mismatch problems by replacing direct persistence-related database accesses with high-level object handling functions.
Hibernate is free as open source software that is distributed under the GNU Lesser General Public License.
Rather than utilize bytecode processing or code generation, Hibernate uses runtime reflection to
determine the persistent properties of a class. The objects to be persisted are defined in a
mapping document, which serves to describe the persistent fields and associations, as well as any
subclasses or proxies of the persistent object. The mapping documents are compiled at
application startup time and provide the framework with necessary information for a class.
Additionally, they are used in support operations, such as generating the database schema or
creating stub Java source files.
Hibernate's primary feature is mapping from Java classes to database tables (and from Java data types to SQL data types). Hibernate also provides data query and retrieval facilities. Hibernate generates the SQL calls and relieves the developer from manual result set handling and object conversion, keeping the application portable to all supported SQL databases, with database portability delivered at very little performance overhead.
MappingMapping Java classes to database table is accomplished through the configuration of an XML file or by using Java Annotation. When using an XML file, Hibernate can generate skeletal source code for the persistence classes. This is unnecessary when annotation is used. Hibernate can use the XML file or the annotation to maintain the database schema.Facilities to arrange one-to-many and many-to-many relationships between classes are provided. In addition to managing association between objects, Hibernate can also manage reflexive associations where an object has a one-to-many relationship with other instances of its own type.
Hibernate supports the mapping of custom value types. This makes the following scenarios possible:
Collections of data objects are typically stored in Java collection objects such as Set and List. Java Generics can be used in Java 5 and higher. Hibernate can be configured to lazy load associated collections. Lazy loading is the default as of Hibernate 3.
Related objects can be configured to cascade operations from one to the other. For example, a parent such as an Album object can be configured to cascade its save and/or delete operation to its child Track objects. This can reduce development time and ensure referential integrity. A dirty checkingfeature avoids unnecessary database write actions by performing SQL updates only on the modified fields of persistent objects.
Hibernate Query Language(HQL)Hibernate provides a SQL inspired language called Hibernate Query Language (HQL) which allows SQL-like queries to be written against Hibernate's data objects. Criteria Queries are provided as an object-oriented alternative to HQL. IntegrationHibernate can be used both in standalone Java applications and in Java EE applications using servlets or EJB session beans.