Chiran Mathur

Ranch Hand
+ Follow
since Feb 07, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chiran Mathur

Could someone explain the difference between the two and what are the rules governing these.
import java.util.*;
class J {
public static void main (String[] args) {
Object i = new ArrayList().listIterator();
System.out.print((i instanceof List)+",");
System.out.print((i instanceof Iterator)+",");
System.out.print(i instanceof ListIterator);
}
}

What is the result of attempting to compile
It prints false, true and true
Whys is first option false?
public class ForSwitch
{
public static void main(String args[])
{
char i;
LOOP: for (i=0;i<5;i++)
{
switch(i++)
{
case '0': System.out.println("A");
case 1: System.out.println("B"); break LOOP;
case 2: System.out.println("C"); break;
case 3: System.out.println("D"); break;
case 4: System.out.println("E");
case 'E' : System.out.println("F");
}
}
}
}
What will it print?
Answer is C and F.
Can anybody explain?
So does one have to remember the ascii value of each character
The numeric value for the letter 'a' is 97.
Which of these code fragments will successfully declare and initialize a variable of type 'char' with this value?




Select 2 correct options
a char ch = 'a';


b char ch = '\97';
It will give illegal escape sequence.

c char ch = '\u0097';
'\u' is used for Unicode values and '97' is not the unicode value of 'a'. ( Unicode value of 'a' is '61', which is actually '97' in decimal)

d char ch = 0x97;
0x means it is a hex number so It will make it 151.

e char ch = 97;



The answer is a and e. Can someone explain this?
I had reschduled my exam once as I was travelling and now I need to reschedule it once more because of some personal emergency. Is that allowed by Prometric? I just want to move it by two days.
Dan,
Thanks a lot for the great tutorials. I am confused about -2 though. Wouldn't -2 be
1111 1101
and therfore the answer will be fffffffd
instead of fffffffe
Please clarify.
Thanks,
class D {
public static void main (String args[]) {
int i1 = ~1;
int i2 = -1;
int i3 = -2;
System.out.print(Integer.toHexString(i1) + ",");
System.out.print(Integer.toHexString(i2) + ",");
System.out.print(Integer.toHexString(i3));
}
}

What is the result of attempting to compile and run the above program?
a. Prints: ffffffff,ffffffff,ffffffff
b. Prints: ffffffff,ffffffff,fffffffe
c. Prints: ffffffff,fffffffe,ffffffff
d. Prints: ffffffff,fffffffe,fffffffe
e. Prints: fffffffe,ffffffff,ffffffff
f. Prints: fffffffe,ffffffff,fffffffe
g. Prints: fffffffe,fffffffe,ffffffff
h. Prints: fffffffe,fffffffe,fffffffe
i. Runtime error
j. Compiler error
k. None of the above
I am somehow just not getting any of the above values. The answer is:f
I would appreciate if you can explain this ind details I tried to do this but couldn't get -1.I used 15 for F value.
long lx=0x0FFFFL;
short ly=(short) lx;

System.out.println("The short value here is"+ly);
or is there a way to find out their values:
See question:
'3b1' is the hex value for the Greek letter alpha in the Unicode.
Write the Unicode literal which can be used to initialize a char variable to alpha.
(Just write what should replace uuuuuu in the following statement?
char alpha = 'uuuuuu' ; )
Could somebody point me ti teh right resource. I am having a hard time understanding this.