Go:
1 2 3 R4R --->Java --->> SCJP1.5 Chapter03 --> Sun Java Certification
Page 1
Question:Arithmetic Operators
Post Your View
AnswersWe know that the bassic operators :
> + addition
> – subtraction
> × multiplication
> / division
class MathTest {
public static void main (String [] args) {
int x = 5 * 3;
int y = x - 4;
System.out.println("x - 4 is " + y); // Prints 11
}
}
one operator we might be n More --- >>
By:UMANG Date:27.02.09
Question:Assigning a Literal That Is Too Large for the Variable
Post Your View
Answers If we trying to assign a literal values then we know that the compilers should that time too big to
fit into the variable.
byte a = 128; // byte can only hold up to 127
The preceding code gives us this error:
TestBytes.java:5: possible loss of precision
found : int
required: byte
byte a = 1 More --- >>
By:UMANG Date:26.02.09
Question:Assigning Floating-Point Numbers
Post Your View
AnswersFloating-point numbers slightly diff assignment behavior than integer types.We know that the every floating-point literal is implicitly a double (64 bits), not a float. If we try to assign a double to a float, the compiler knows we don’t have enough room in a 32-bit float container to hold the preci More --- >>
By:UMANG Date:26.02.09
Question:Assigning One Primitive Variable to Another Primitive Variable
Post Your View
AnswersWhen we assign one primitive to another the contents of the right-hand variable are copied, for example,
int a = 6;
int b = a;
We used the variable a only to copy its contents. At this point, a and b
have identical contents (in other words, identical values), but if we change the co More --- >>
By:UMANG Date:26.02.09
Question:Assigning One Reference Variable to Another
Post Your View
AnswersIn the primitive variables , An assigment of one variable to another means the the aontent of one varibale to copy with another.Object reference variables work exactly the same way. The contents of a reference variable are a bit pattern.we assign an existing instance of an object to a new
reference More --- >>
By:UMANG Date:26.02.09
Question:Assignment Operators
Post Your View
AnswersAssignment Operators is bassically a assigning a value seems straightforword ,primitive and reference variable assignments, nut before we wanna know about what's we have in the back up and peek inside of a variable.Variables are just bit holders, with a designated type. and we also can have an int More --- >>
By:UMANG Date:26.02.09
Question:Bitwise Complement Operator
Post Your View
AnswersThe ~ operator is a flip-the-bits operator. It will change all 1s to 0s and vice versa.
see this following code:
class Bitwise {
public static void main(String [] args) {
int x = 5;
System.out.println("x is initially " + x);
x = ~x;
System.out.println("~x is equal to " + x);
}
}
This progr More --- >>
By:UMANG Date:27.02.09
Question:Bitwise Operators
Post Your View
AnswersThe bitwise operators take two individual bit numbers, then use AND/OR to
determine the result on a bit-by-bit basis. There are three bitwise operators:
■ & AND
> | inclusive OR
> ^ exclusive OR
The & operator compares corresponding bits between two numbers. If both bits are 1, the final More --- >>
By:UMANG Date:27.02.09
Question:Casting Primitives
Post Your View
AnswersCreate a float number type of any value, and assign it to a short using casting.
1. Declare a float variable: float f = 234.56F;
2. Assign the float to a short: short s = (short)f; More --- >>
By:UMANG Date:27.02.09
Question:Comparison Operators
Post Your View
AnswersComparision operator result always in the boolean values we also can say its gives output only in the true or false .This boolean value is most often used in an if test, as follows:
int x = 8;
if (x < 9) {
// do something
}
but the resulting value can also be assigned directly to a boole More --- >>
By:UMANG Date:26.02.09
Question:Conditional Operator
Post Your View
AnswersThe condition operator is is a bassicaly a tenory oprator its mainly used for the boolean expressions, its semilar as a if statement but some diff its not executing a block of code if the test is true, a conditional operator will assign a value to a variable, we can also say the goal of the conditio More --- >>
By:UMANG Date:27.02.09
Question:Does Java Use Pass-By-Value Semantics?
Post Your View
Answersif java passes objects by passing the reference variable instead its means the java uses pass-by-reference for objects, but its not a exactly.Java is actually pass-by-value for all variables running within a single VM. Pass-by-value means pass-by-variable-value. And that means, pass-by-copy-of-the-v More --- >>
By:UMANG Date:27.02.09
Go:
1 2 3
Contact Us
|