Whats The Difference Between: Int Length 5 Int Breadth 10 Int Area Length Breadth
Whats The Difference Between: Int Length 5 Int Breadth 10 Int Area Length Breadth
and
final int length = 5;
final int breadth = 10;
int area = length * breadth;
dont scroll down until you have thought over the answer
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
gave it a thought ?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
sure ?
.
.
.
.
.
.
.
.
.
.
.
Ok then heres the answer...
In the second code snippet multiplication is done at compile time.
In first multiplication is done at Runtime.
Reason
Java compiler uses something known as Constant Folding. Constant folding refers to the
compiler precalculating constant expressions.
QUESTION2
Difference between Vector and ArrayList?
QUESTION3
Difference between Swing and Awt?
A: AWT are heavy-weight componenets. Swings are light-weight components. Hence swing
works faster than AWT.
QUESTION4
class IncDemo
{
public static void main(String args[])
{
int a=1;
int b=++a++;
System.out.println(b);
}
}
C:\jdk1.5.0\bin>javac IncDemo.java
IncDemo.java:6: unexpected type
required: variable
found : value
int b=++a++;
^
1 error
QUESTION5
class P
{
static
System.out.print("Great ");
NMM.main(null);
System.out.print("Programmer ");
System.exit(0);
System.out.print("Java ");
QUESTION7:
From where the main() method in java??
Ans: Java Virtual machine.
QUESTION8
class Min
{
public static void main(String args[])
{
int min = 50;
min(min, 40, 20);
System.out.println("Minimum of 20,40 and 50 is"+min);
}
String s="pavan";
char c = s.charAt(3);
System.out.println(c);
}
}
Output: a
QUESTION 10