Ideally, transactions should be serializable. Transactions are said to be serializable if the results of running transactions simultaneously are the same as the results of running them serially-that is, one after the other. It is not important which transaction executes first, only that the result does not reflect any mixing of the transactions.
For example, suppose transaction A multiplies data values by 2 and transaction B adds 1 to data values. Now suppose that there are two data values: 0 and 10. If these transactions are run one after the other, the new values will be 1 and 21 if transaction A is run first, or 2 and 22 if transaction B is run first. But what if the order in which the two transactions are run is different for each value? If transaction A is run first on the first value and transaction B is run first on the second value, the new values are 1 and 22. If this order is reversed, the new values are 2 and 21. The transactions are serializable if 1, 21 and 2, 22 are the only possible results. The transactions are not serializable if 1, 22 or 2, 21 is a possible result.
So why is serializability desirable? In other words, why is it important that it appears that one transaction finishes before the next transaction starts? Consider the following problem. A salesman is entering orders at the same time a clerk is sending out bills. Suppose the salesman enters an order from Company X but does not commit it; the salesman is still talking to the representative from Company X. The clerk requests a list of all open orders and discovers the order for Company X and sends them a bill. Now the representative from Company X decides they want to change their order, so the salesman changes it before committing the transaction. Company X gets an incorrect bill.
If the salesman's and clerk's transactions were serializable, this problem would never have occurred. Either the salesman's transaction would have finished before the clerk's transaction started, in which case the clerk would have sent out the correct bill, or the clerk's transaction would have finished before the salesman's transaction started, in which case the clerk would not have sent a bill to Company X at all.
Yes, please do. Here is an example:
#include <stdio.h>
int main (void)
{ puts ("Hello, World"); return 0; }
Declaration of two dimentional array in functions?
Possible.
void foo (void)
{
int array [10][20];
...
}
How big in bytes are each of the 6 numeric primitive data types?
What is default object in java?
I don't think there is such a thing as a "default object". The default class, for inheritance purposes, is called "Object".
Return an iterator to the string if it exists, or the container's end iterator if it does not.
Write a C program to find the sum of all prime numbers in an array?
Borrowing the isPrime function from another answer of mine. Note that this will result in terrible performance for large arrays of numbers. (You should look into one of the sieve algorithms for this)
// returns 1 if n is prime, 0 otherwise
void isPrime(const int n) {
// We know that if n is composite, then we will find a factor in the range [2,sqrt(n)]
// so we compute the square root only once to limit our number of calculations.
const int sqrt_n = sqrt(n);
// Iterate through possible factors
int i;
for( i = 2; i <= sqrt_n; ++i ) {
// If n is divisible by i (n%i==0) then we have a factor
if(!(n % i)) {
return 0;
}
}
// If we get here, we know n has no factors other than itself and 1
return 1;
}
// returns the sum of all prime numbers in nums
int findPrimeSum(const int numsLength, const int[] nums) {
int sum = 0;
// iterate through nums and add up all the primes
int i;
for(i = 0; i < numsLength; ++i) {
if( isPrime(nums[i] ) {
sum += nums[i];
}
}
return sum;
}
class is template of object and object is instance of a class
What operators work differently when placed before rather than after an operand?
unary operators like ++,--
What is the task of main method in a java program?
The main method is simply an entry point to your executable code. When you run a Java program, it looks for a main method as the first section of code to execute, which is why all of your programs start there.
A compiler converts a program in one programming language into a program in another programming language. Often the conversion is into a language that can be understood directly by the hardware.
A while loop evaluates the conditional expression at the start of each iteration, whereas a do..while loop evaluates the conditional expression at the end of each iteration. Thus the do..while loop always executes at least one iteration.
Write a program in java to print letters of a String in steps?
/* INPUT: Holy Home
* OUTPUT:H
* ------------ o
* --------------l
* ---------------y
* ---------------- _______________//The '-' are spaces
* ------------------H
* --------------------o
* ---------------------m
* -----------------------e
*
*/
import java.io.*;
class StyleString
{
protected static void main()throws IOException
{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the String: ");
String s=in.readLine();
for(byte i=0;i<s.length();i++)
{
System.out.println();
for(byte j=0;j<i;j++)
System.out.print(' ');
System.out.print(s.charAt(i));
}
}
}
Where can one find more information about String Class Java?
There are many places one can go to learn more about the String Class in the programming language data. Stack Overflow is a great resource for any coding problems and is a good starting point.
It can easily be explained by the fact that Java does not compile to object code. Java compiles to byte code that is suitable for interpretation by the Java virtual machine. C++ compiles to native machine code and therefore does not require interpretation of any kind. As a result, C++ programs run somewhat quicker than equivalent Java programs. However, because Java is interpreted, it is highly portable. Any machine with a Java virtual machine implementation (which is pretty much every device today) can run Java programs built from a single compilation. C++ requires that the code be written specifically for each platform and that the source be compiled separately upon each supported platform.
Which is more important class or object and why and which comes first?
Class is obviously more important than an object because an object is an instance of a class. A class may contain many objects, all of which are instances of that particular class. Class is also called the object factory because it contains all the statements needed to create an object and its attributes. A class also contains the statements that describe the operations that the created objejct will be able to perform. Therefor a class is more important and obviously come first.
How many constructors are there for the string class?
The String class has multiple Constructors. Some of them are:
1. String - new String(String val)
2. Character Array - new String(char[] array)
3. Character Array with index positions - new String(char[] array. int start, int end)
Difference between advanced java and core java?
There is nothing like core and advanced java. Actually SUN Corporation released three versions(editions) of Java. 1. Standard edition(J2SE). 2. Enterprise edition(J2EE). 3. Mobile edition(J2ME). Core and Advanced Java are the names given by some people which is wrongly meant. Second Answer These terms aren't an actual part of the Java language or the software typically downloaded to create programs (such as the JRE [Java Runtime Environment], or JDK, or GlassFish, etc). The terms "core Java" and "advanced Java" have relevance only in terms of a series of books. It's the same thing as if a new author published a book and decided to call it "Intermediate Java". It's simply a distinction made by the authors / publishers for the content to be in the specific books. So, the short of it is, they're just references to titles from books.
Java variables act as object or not?
How a Java variable would act depends on the variable's data type. Variables of the primitive data types like int, char, float etc would not act as objects. But apart from them, all other data types would act as Objects. Almost all data types would extend from java.lang.Object and would behave as objects.
What is a constructor and what are its special properties?
A constructor creates an Object of 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 few classes you may have to initialize a few of the variables to values apart from their predefined data type specific values. If java initializes variables it would default them to their variable type specific 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 of code can be placed inside the constructor so that the initialization would happen when the class is instantiated.
Properties:
1. You need not code them explicitly. Java will automatically place a default constructor
2. You can pass arguments to the constructor
3. They can return only an object of type of that class
4. They can be made private
5. They would be executed always (Everytime a class is instantiated)
Can the remainder or modulus operator be used with floating point operands?
Very well YES
public class ModTest {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(10.5%2);
}
}
Output of the above program is: 0.5
What is coping with complexity in oops?
The size and complexity of a small program is small and simple. Whereas, the size and complexity of a large application program is large and hard. The complexity in dealing with the problems to build a large application depends on the 'composition' and 'abstraction' mechanisms.
Which application server support java platform?
All major servers like Weblogic, Webspher, Tomcat support Java Platform
How do you create an instance of inner class outside outer class in java?
is given below
package com.test.reflection;
public class Outer
{
public static class Nested
{
public void printMesg(String body)
{
System.out.println(body);
}
}
public class Inner
{
public void printMesg(String body)
{
System.out.println(body);
}
}
}
package com.test.reflection;
import com.test.reflection.Outer.
Nested;
public class AnotherClass {
public static void main(String[] args){
try {
//Bar b=(Bar) Foo.Bar.class.getConstructors()[0].newInstance(new Foo());
//b.printMesg("hello");
Nested nested=new Nested();
nested.printMesg("nested class");
Outer.Inner inner=new Outer().new Inner();
inner.printMesg("Inner class");
//b1.printMesg("static");
} catch (IllegalArgumentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}