Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

exam qs- operators and assgnmts- help!

Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please explian , thanks!
1.The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?
A]char ch = 65
B]char ch ='\65'
C]char ch ='\0041'
D]char ch ='A'
E]char ch ="A"

2. Given the following class definitions, which expression identifies whether the object referred to by obj was created by instantiating class B rather than classes A, C and D?
class A {}
class B extends A {}
class C extends B {}
class D extends A {}
A]obj instanceof B
B]obj instanceof A &&!(obj instanceof C)
C]obj instanceof B &&!(obj instanceof C)
D]obj instanceof C | | obj instanceof D
E]obj instance of A) &&!(obj instanceof C) &&!(obj instanceof D

3.Given the following code, which statements concerning the objects referenced through the member variables i, j and k are true, given that any thread may call the methods a, b and c at any time?
class Counter {
int v = 0;
synchronized void inc() { v++; }
synchronized void dec() { v--; }
public class Q7ed5 {
Counter i;
Counter j;
Counter k;
public synchronized void a() {;
public synchronized void b() {;;;
i.dec(); j.dec(); k.dec();
public void c() {;
A]i.v is guarenteed to be 0 or 1
B]j.v is guarenteed to be 0 or 1
C]k.v is guarenteed to be 0 or 1
D]j.v will always be greater than or equal to k.v at any given time
E]k.v will always be greater than j.v at any given time
4. Which statements are true concerning the effect of the >> and >>> operators?
A]For non negative values fo the left oprerand the >> and >>> operators will have the same effect
B]The result of (-1>>1) is 0
C]The result of -1>>>1 is -1
D]The value returned by >>> will never be negative as long as the value of the right operand is equal to or greater than 1
E]When using the >> operator, the leftmost bit of the bit representation of the resulting value will always be the same bit value as the left

5. What will be the result of attempting to compile and run the following code?
public class Q6b0c {
public static void main(String args[]) {
int i = 4;
float f = 4.3;
double d = 1.8;
int c = 0;
if (i == f) c++;
if (((int) (f + d)) == ((int) f + (int) d)) c += 2;
A] It will not compile
6. Which one of these are valid at position 1?
public class Q6db8 {
int a;
int b = 0;
static int c;
public void m() {
int d;
int e = 0;
// Position 1
Ruth Stout was famous for gardening naked. Just like this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic