14 dic 2012
[Cerrado] Sorteo de Nexus 7 comprando en amazon.es durante estas Navidades
Si hacéis una compra dejadme un comentario, cuantos números os tocaría, yo lo compruebo y os asigno un número para el sorteo, así de fácil. Cuando la fecha llegue y tengamos un cierto número de participantes, está claro que si hay pocos replantearé el sorteo de otro modo. Si la convocatoria funciona no descarto mejorar el sorteo, y sobre todo repetirlo con otros gadgets.
Final: Se ha acabado la campaña navideña y viendo la poca repercusión y ya que sólo hemos tenido un participante que me envió un correo, doy por cancelado el sorteo, a David le haré un traspaso de la comisión que reciba de amazon a través de paypal. Si alguien más participó aun puede avisarme y le haré el mismo trato.
Para los que lleguéis tarde si os interesa podéis obtener descuentos para vuestras compras en amazon.es y participar en promociones en nuestrá página amiga #WhereToBuy
7 dic 2012
Preparación para Certificación SCJP 1Z0-851. Tema 3
Continuando con esta "saga" de posts sobre la preparación para realizar el examen de certificación de java SCJP 1Z0-851.
Question 1
Given:
1. class Scoop {
2. static int thrower() throws Exception { return 42; }
3. public static void main(String [] args) {
4. try {
5. int x = thrower();
6. } catch (Exception e) {
7. x++;
8. } finally {
9. System.out.println("x = " + ++x);
10. } } }
What is the result?
a. x = 42
b. x = 43
c. x = 44
d. Compilation fails.
e. The code runs with no output.
Answer: D
Question 2
Which are true? (Choose all that apply.)
a. It is appropriate to use assertions to validate arguments to methods marked public.
b. It is appropriate to catch and handle assertion errors.
c. It is NOT appropriate to use assertions to validate command-line arguments.
d. It is appropriate to use assertions to generate alerts when you reach code that should not be reachable.
e. It is NOT appropriate for assertions to change a program
Answer: C, D and E
Question 3
Given:
1. class Emu {
2. static String s = "-";
3. public static void main(String[] args) {
4. try {
5. throw new Exception();
6. } catch (Exception e) {
7. try {
8. try { throw new Exception();
9. } catch (Exception ex) { s += "ic "; }
10. throw new Exception(); }
11. catch (Exception x) { s += "mc "; }
12. finally { s += "mf "; }
13. } finally { s += "of "; }
14. System.out.println(s);
15. } }
What is the result?
Seleccione una respuesta.
a. -ic of
b. -mf of
c. -mc mf
d. -ic mf of
e. -ic mc mf of
f. -ic mc of mf
g. Compilation fails.
Answer: E
Question 4
Given:
1. class Mineral { }
2. class Gem extends Mineral { }
3. class Miner {
4. static int x = 7;
5. static String s = null;
6. public static void getWeight(Mineral m) {
7. int y = 0 / x;
8. System.out.print(s + " ");
9. }
10. public static void main(String[] args) {
11. Mineral[] ma = {new Mineral(), new Gem()};
12. for(Object o : ma)
13. getWeight((Mineral) o);
14. }
15. }
And the command-line invocation:
java Miner.java
What is the result?
Seleccione una respuesta.
a. null
b. null null
c. A ClassCastException is thrown.
d. A NullPointerException is thrown.
e. A NoClassDefFoundError is thrown.
f. An ArithmeticException is thrown.
g. An IllegalArgumentException is thrown.
h. An ArrayIndexOutOfBoundsException is thrown.
Answer: E
Question 5
Which are most typically thrown by an API developer or an application developer as opposed to being thrown by the JVM? (Choose all that apply.)
a. ClassCastException
b. IllegalStateException
c. NumberFormatException
d. IllegalArgumentException
e. ExceptionInInitializerError
Answer: B, C and D
6
Given two files:
1. class One {
2. public static void main(String[] args) {
3. int assert = 0;
4. }
5. }
1. class Two {
2. public static void main(String[] args) {
3. assert(false);
4. }
5. }
And the four command-line invocations:
javac -source 1.3 One.java
javac -source 1.4 One.java
javac -source 1.3 Two.java
javac -source 1.4 Two.java
What is the result? (Choose all that apply.)
a. Only one compilation will succeed.
b. Exactly two compilations will succeed.
c. Exactly three compilations will succeed.
d. All four compilations will succeed.
e. No compiler warnings will be produced.
f. At least one compiler warning will be produced.
Answer: B and F
Question 7
Given:
1. import java.io.*;
2. class Master {
3. String doFileStuff() throws FileNotFoundException { return "a"; }
4. }
5. class Slave extends Master {
6. public static void main(String[] args) {
7. String s = null;
8. try { s = new Slave().doFileStuff();
9. } catch ( Exception x) {
10. s = "b"; }
11. System.out.println(s);
12. }
13. // insert code here
14. }
Which, inserted independently at
// insert code here
, will compile, and produce the output b? (Choose all that apply.)
a. String doFileStuff() { return "b"; }
b. String doFileStuff() throws IOException { return "b"; }
c. String doFileStuff(int x) throws IOException { return "b"; }
d. String doFileStuff() throws FileNotFoundException { return "b"; }
e. String doFileStuff() throws NumberFormatException { return "b"; }
f. String doFileStuff() throws NumberFormatException, FileNotFoundException { return "b"; }
Answer: A, D, E, F
Question 8
Given:
1. class Input {
2. public static void main(String[] args) {
3. String s = "-";
4. try {
5. doMath(args[0]);
6. s += "t "; // line 6
7. }
8. finally { System.out.println(s += "f "); }
9. }
10. public static void doMath(String a) {
11. int y = 7 / Integer.parseInt(a);
12. }
13. }
And the command-line invocations:
java Input
java Input 0
Which are true? (Choose all that apply.)
a. Line 6 is executed exactly 0 times.
b. Line 6 is executed exactly 1 time.
c. Line 6 is executed exactly 2 times.
d. The finally block is executed exactly 0 times.
e. The finally block is executed exactly 1 time.
f. The finally block is executed exactly 2 times.
g. Both invocations produce the same exceptions.
h. Each invocation produces a different exception.
Answer: A, F and H
Question 9
Given:
1. class Plane {
2. static String s = "-";
3. public static void main(String[] args) {
4. new Plane().s1();
5. System.out.println(s);
6. }
7. void s1() {
8. try { s2(); }
9. catch (Exception e) { s += "c"; }
10. }
11. void s2() throws Exception {
12. s3(); s += "2";
13. s3(); s += "2b";
14. }
15. void s3() throws Exception {
16. throw new Exception();
17. } }
What is the result?
a. -
b. -c
c. -c2
d. -2c
e. -c22b
f. -2c2b
g. -2c2bc
h. Compilation fails.
Answer: B
Question 10
Given:
try { int x = Integer.parseInt("two"); }
Which could be used to create an appropriate catch block? (Choose all that apply.)
a. ClassCastException
b. IllegalStateException
c. NumberFormatException
d. IllegalArgumentException
e. ExceptionInInitializerError
f. ArrayIndexOutOfBoundsException
Answer: C and D
11
Given:
1. class Ping extends Utils {
2. public static void main(String [] args) {
3. Utils u = new Ping();
4. System.out.print(u.getInt(args[0]));
5. }
6. int getInt(String arg) {
7. return Integer.parseInt(arg);
8. }
9. }
10. class Utils {
11. int getInt(String x) throws Exception { return 7; }
12. }
And the following three possible changes:
C1. Declare that main() throws an Exception.
C2. Declare that Ping.getInt() throws an Exception.
C3. Wrap the invocation of getInt() in a try / catch block.
Which change(s) allow the code to compile? (Choose all that apply.)
Seleccione al menos una respuesta.
a. Just C1 is sufficient.
b. Just C2 is sufficient.
c. Just C3 is sufficient.
d. Both C1 and C2 are required.
e. Both C1 and C3 are required.
f. Both C2 and C3 are required.
g. All three changes are required.
Answer: A and C
Question 12
Given:
1. class Swill {
2. public static void main(String[] args) {
3. String s = "-";
4. switch(TimeZone.CST) {
5. case EST: s += "e";
6. case CST: s += "c";
7. case MST: s += "m";
8. default: s += "X";
9. case PST: s += "p";
10. }
11. System.out.println(s);
12. }
13. }
14. enum TimeZone {EST, CST, MST, PST }
What is the result?
Seleccione una respuesta.
a. -c
b. -X
c. -cm
d. -cmp
e. -cmXp
f. Compilation fails.
g. An exception is thrown at runtime.
Answer: E
20 nov 2012
Preparación para Certificación SCJP 1Z0-851. Tema 2
Question 1
Which statement(s) are true? (Choose all that apply.)
a. Has-a relationships always rely on inheritance.
b. Has-a relationships always rely on instance variables.
c. Has-a relationships always require at least two class types.
d. Has-a relationships always rely on polymorphism.
e. Has-a relationships are always tightly coupled.
Answer: B
Question 2
Given the following,
1. interface Base {
2. boolean m1 ();
3. byte m2(short s);
4. }
Which code fragments will compile? (Choose all that apply.)
a.
interface Base2 implements Base { }
b.
abstract class Class2 extends Base {
public boolean m1() { return true; } }
c.
abstract class Class2 implements Base { }
d.
abstract class Class2 implements Base {
public boolean m1() { return (true); } }
e.
class Class2 implements Base {
boolean m1() { return false; }
byte m2(short s) { return 42; } }
Answer: C and D
Question 3
Which declare a compilable abstract class? (Choose all that apply.)
a. public abstract class Canine { public Bark speak(); }
b. public abstract class Canine { public Bark speak() { return null; } }
c. public class Canine { public abstract Bark speak(); }
d. public class Canine abstract { public abstract Bark speak(); }
Answer: B
Question 4
Which is true? (Choose all that apply.)
a. "X extends Y" is correct if and only if X is a class and Y is an interface.
b. "X extends Y" is correct if and only if X is an interface and Y is a class.
c. "X extends Y" is correct if X and Y are either both classes or both interfaces.
d. "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces.
Answer: C
Question 5
Which method names follow the JavaBeans standard? (Choose all that apply.)
a. addSize
b. getCust
c. deleteRep
d. isColorado
e. putDimensions
Answer: B and D
Question 6
Given:
1. enum Animals {
2. DOG("woof"), CAT("meow"), FISH("burble");
3. String sound;
4. Animals(String s) { sound = s; }
5. }
6. class TestEnum {
7. static Animals a;
8. public static void main(String [] args) {
9. System.out.println(a.DOG.sound + " " + a.FISH.sound);
10. }
11. }
What is the result?
a. woof burble
b. Multiple compilation errors
c. Compilation fails due to an error on line 2
d. Compilation fails due to an error on line 3
e. Compilation fails due to an error on line 4
f. Compilation fails due to an error on line 9
Answer: A
Question 7
Given:
1. enum A { A }
2. class E2 {
3. enum B { B }
4. void C() {
5. enum D { D }
6. }
7. }
Which statements are true? (Choose all that apply.)
a. The code compiles.
b. If only line 1 is removed the code compiles.
c. If only line 3 is removed the code compiles.
d. If only line 5 is removed the code compiles.
e. If lines 1 and 3 are removed the code compiles.
f. If lines 1, 3 and 5 are removed the code compiles.
Answer: D and F
Question 8
Given:
1. class Programmer {
2. Programmer debug() { return this; }
3. }
4. class SCJP extends Programmer {
5. // insert code here
6. }
Which, inserted at line 5, will compile? (Choose all that apply.)
a. Programmer debug() { return this; }
b. SCJP debug() { return this; }
c. Object debug() { return this; }
d. int debug() { return 1; }
e. int debug(int x) { return 1; }
f. Object debug(int x) { return this; }
Answer: A, B, E and F
Question 9
Given:
1. class Uber {
2. static int y = 2;
3. Uber(int x) { this(); y = y * 2; }
4. Uber() { y++; }
5. }
6. class Minor extends Uber {
7. Minor() { super( y ); y = y + 3; }
8. public static void main(String [] args) {
9. new Minor();
10. System.out.println( y );
11. } }
What is the result?
Seleccione una respuesta.
a. 6
b. 7
c. 8
d. 9
e. Compilation fails.
f. An exception is thrown.
Answer: D
Question 10
Which statement(s) are true? (Choose all that apply.)
a. Cohesion is the OO principle most closely associated with hiding implementation details.
b. Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs.
c. Cohesion is the OO principle most closely associated with making sure that a class is designed with a single, well-focused purpose.
d. Cohesion is the OO principle most closely associated with allowing a single object to be seen as having many types.
Answer: C
Question 11
Given:
1. class Dog { }
2. class Beagle extends Dog { }
3.
4. class Kennel {
5. public static void main(String [] arfs) {
6. Beagle b1 = new Beagle();
7. Dog dog1 = new Dog();
8. Dog dog2 = b1;
9. // insert code here
10. }
11.}
Which, inserted at line 9, will compile? (Choose all that apply.)
a. Beagle b2 = (Beagle) dog1;
b. Beagle b3 = (Beagle) dog2;
c. Beagle b4 = dog2;
d. None of the above statements will compile
Answer: A and B
Question 12
Given the following,
1. class X { void do1() { } }
2. class Y extends X { void do2() { } }
3. 4. class Chrome {
5. public static void main(String [] args) {
6. X x1 = new X();
7. X x2 = new Y();
8. Y y1 = new Y();
9. // insert code here
10. } }
Which, inserted at line 9, will compile? (Choose all that apply.)
a. x2.do2();
b. (Y)x2.do2();
c. ((Y)x2).do2();
d. None of the above statements will compile.
Answer: C
Question 13
Given:
1. class Clidders {
2. public final void flipper() { System.out.println("Clidder"); }
3. }
4. public class Clidlets extends Clidders {
5. public void flipper() {
6. System.out.println("Flip a Clidlet");
7. super.flipper();
8. }
9. public static void main(String [] args) {
10. new Clidlets().flipper();
11. }
12.}
What is the result?
a. Flip a Clidlet
b. Flip a Clidder
c. Flip a Clidder
d. Flip a Clidlet
e. Flip a Clidlet
f. Flip a Clidder
g. Compilation fails.
Answer: G
Question 14
Given:
public abstract interface Frobnicate { public void twiddle(String s); }
Which is a correct class? (Choose all that apply.)
a.
public abstract class Frob implements Frobnicate {
public abstract void twiddle(String s) { }
}
b.
public abstract class Frob implements Frobnicate { }
c.
public class Frob extends Frobnicate {
public void twiddle(Integer i) { }
}
d.
public class Frob implements Frobnicate {
public void twiddle(Integer i) { }
}
e.
public class Frob implements Frobnicate {
public void twiddle(String i) { }
public void twiddle(Integer s) { }
}
Answer: B and E
Question 15
Given:
1. class Top {
2. public Top(String s) { System.out.print("B"); }
3. }
4. public class Bottom2 extends Top {
5. public Bottom2(String s) { System.out.print("D"); }
6. public static void main(String [] args) {
7. new Bottom2("C");
8. System.out.println(" ");
9. } }
What is the result?
Seleccione una respuesta.
a. BD
b. DB
c. BDC
d. DBC
e. Compilation fails.
Answer: E
Question 16
Select the two statements that best indicate a situation with low coupling. (Choose two.)
a. The attributes of the class are all private.
b. The class refers to a small number of other objects.
c. The object contains only a small number of variables.
d. The object is referred to using an anonymous variable, not directly.
e. The reference variable is declared for an interface type, not a class. The interface provides a small number of methods.
f. It is unlikely that changes made to one class will require any changes in another.
Answer: E and F
Question 17
Given:
1. class Clidder {
2. private final void flipper() { System.out.println("Clidder"); }
3. }
4. public class Clidlet extends Clidder {
5. public final void flipper() { System.out.println("Clidlet"); }
6. public static void main(String [] args) {
7. new Clidlet().flipper();
8. } }
What is the result?
Seleccione una respuesta.
a. Clidlet
b. Clidder
c. Clidder
Clidlet
d. Clidlet
Clidder
e. Compilation fails.
Answer: A
Question 18
Given:
1. class Plant {
2. String getName() { return "plant"; }
3. Plant getType() { return this; }
4. }
5. class Flower extends Plant {
6. // insert code here
7. }
8. class Tulip extends Flower { }
Which statement(s), inserted at line 6, will compile? (Choose all that apply.)
a. Flower getType() { return this; }
b. String getType() { return "this"; }
c. Plant getType() { return this; }
d. Tulip getType() { return new Tulip(); }
Answer: A, C and D
Question 19
Given:
public class MyOuter {
public static class MyInner { public static void foo() { } }
}
Which, if placed in a class other than MyOuter or MyInner, instantiates an instance of the
nested class?
a.
MyOuter.MyInner m = new MyOuter.MyInner();
b.
MyOuter.MyInner mi = new MyInner();
c.
MyOuter m = new MyOuter();
MyOuter.MyInner mi = m.new MyOuter.MyInner();
d.
MyInner mi = new MyOuter.MyInner();
Answer: A
Question 20
Given:
1. public class HorseTest {
2. public static void main(String[] args) {
3. class Horse {
4. public String name;
5. public Horse(String s) {
6. name = s;
7. }
8. }
9. Object obj = new Horse("Zippo");
10. Horse h = (Horse) obj;
11. System.out.println(h.name);
12. }
13. }
What is the result?
Seleccione una respuesta.
a. An exception occurs at runtime at line 10.
b. Zippo
c. Compilation fails because of an error on line 3.
d. Compilation fails because of an error on line 9.
e. Compilation fails because of an error on line 10.
f. Compilation fails because of an error on line 11.
Answer: B
Question 21
Given:
1. public class HorseTest {
2. public static void main(String[] args) {
3. class Horse {
4. public String name;
5. public Horse(String s) {
6. name = s;
7. }
8. }
9. Object obj = new Horse("Zippo");
10. System.out.println(obj.name);
11. }
12. }
What is the result?
Seleccione una respuesta.
a. An exception occurs at runtime at line 10.
b. Zippo
c. Compilation fails because of an error on line 3.
d. Compilation fails because of an error on line 9.
e. Compilation fails because of an error on line 10.
Answer: E
Question 22
Given:
1. public abstract class AbstractTest {
2. public int getNum() {
3. return 45;
4. }
5. public abstract class Bar {
6. public int getNum() {
7. return 38;
8. }
9. }
10. public static void main(String[] args) {
11. AbstractTest t = new AbstractTest() {
12. public int getNum() {
13. return 22;
14. }
15. };
16. AbstractTest.Bar f = t.new Bar() {
17. public int getNum() {
18. return 57;
19. }
20. };
21. System.out.println(f.getNum() + " " + t.getNum());
22. } }
What is the result?
Seleccione una respuesta.
a. 57 22
b. 45 38
c. 45 57
d. An exception occurs at runtime.
e. Compilation fails.
Answer: A
Question 23
Which are true about a static nested class? (Choose all that apply.)
Seleccione al menos una respuesta.
a. You must have a reference to an instance of the enclosing class in order to instantiate it.
b. It does not have access to non-static members of the enclosing class.
c. Its variables and methods must be static.
d. If the outer class is named MyOuter, and the nested class is named MyInner, it can be instantiated using new MyOuter.MyInner();.
e. It must extend the enclosing class.
Answer: B and D
Question 24
Given:
public interface Runnable { void run(); }
Which construct an anonymous inner class instance? (Choose all that apply.)
a.
Runnable r = new Runnable() { };
b.
Runnable r = new Runnable(public void run() { });
c.
Runnable r = new Runnable { public void run(){ } };
d.
Runnable r = new Runnable() {public void run{ } };
e.
System.out.println(new Runnable() {public void run() { } });
f.
System.out.println(new Runnable(public void run() { } ));
Answer: E
Question 25
Given:
1. class Boo {
2. Boo(String s) { }
3. Boo() { }
4. }
5. class Bar extends Boo {
6. Bar() { }
7. Bar(String s) {super(s);}
8. void zoo() {
9. // insert code here
10. }
11. }
Which create an anonymous inner class from within class Bar? (Choose all that apply.)
Seleccione al menos una respuesta.
a. Boo f = new Boo(24) { };
b. Boo f = new Bar() { };
c. Boo f = new Boo() {String s; };
d. Bar f = new Boo(String s) { };
e. Boo f = new Boo.Bar(String s) { };
Answer: B and C
Question 26
Given:
1. class Foo {
2. class Bar{ }
3. }
4. class Test {
5. public static void main(String[] args) {
6. Foo f = new Foo();
7. // Insert code here
8. }
9. }
Which, inserted at line 7, creates an instance of Bar? (Choose all that apply.)
a. Foo.Bar b = new Foo.Bar();
b. Foo.Bar b = f.new Bar();
c. Bar b = new f.Bar();
d. Bar b = f.new Bar();
e. Foo.Bar b = new f.Bar();
Answer: B
Question 27
Which are true about a method-local inner class? (Choose all that apply.)
a. It must be marked final.
b. It can be marked abstract.
c. It can be marked public.
d. It can be marked static.
e. It can access private members of the enclosing class.
Answer: B and E
Question 28
Which are true about an anonymous inner class? (Choose all that apply.)
a. It can extend exactly one class and implement exactly one interface.
b. It can extend exactly one class and can implement multiple interfaces.
c. It can extend exactly one class or implement exactly one interface.
d. It can implement multiple interfaces regardless of whether it also extends a class.
e. It can implement multiple interfaces if it does not extend a class.
Answer: C
Question 29
Given:
1. public class Foo {
2. Foo() {System.out.print("foo");}
3. class Bar{
4. Bar() {System.out.print("bar");}
5. public void go() {System.out.print("hi");}
6. }
7. public static void main(String[] args) {
8. Foo f = new Foo();
9. f.makeBar();
10. }
11. void makeBar() {
12. (new Bar() {}).go();
13. }
14. }
What is the result?
Seleccione una respuesta.
a. Compilation fails.
b. An error occurs at runtime.
c. foobarhi
d. barhi
e. hi
f. foohi
Answer: C
Question 30
Given:
1. public class TestObj {
2. public static void main(String[] args) {
3. Object o = new Object() {
4. public boolean equals(Object obj) {
5. return true;
6. }
7. }
8. System.out.println(o.equals("Fred"));
9. }
10. }
What is the result?
a. An exception occurs at runtime.
b. true
c. fred
d. Compilation fails because of an error on line 3.
e. Compilation fails because of an error on line 4.
f. Compilation fails because of an error on line 8.
g. Compilation fails because of an error on a line other than 3, 4, or 8.
Answer: G
Question 31
Given:
1. class Zing {
2. protected Hmpf h;
3. }
4. class Woop extends Zing { }
5. class Hmpf { }
Which is true? (Choose all that apply.)
a. Woop is-a Hmpf and has-a Zing.
b. Zing is-a Woop and has-a Hmpf.
c. Hmpf has-a Woop and Woop is-a Zing.
d. Woop has-a Hmpf and Woop is-a Zing.
e. Zing has-a Hmpf and Zing is-a Woop.
Answer: D
9 oct 2012
Preparación para Certificación SCJP 1Z0-851. Tema 1
Hace unos días que he empezado un cursillo para sacar una certificación de java 6, el antiguo CX-310-065, que ahora que Oracle ha decidido cambiar el código para estandarizar con sus formaciones pasa a ser el 1Z0-851.
Quiero compartir algo de material que voy a usar para la preparación del test, os dejo el test que he realizado sobre el tema 1, si buscáis estas mismas preguntas las podéis encontrar en otras webs.
1. Which is true? (Choose all that apply.)
A. The invocation of an object's finalize () method is always the last thing that happens before an object is garbage collected (GCed).
B. When a stack variable goes out of scope it is eligible for GC.
C. Some reference variables live on the stack, and some live on the heap.
D. Only objects that have no reference variables referring to them can be eligible for GC.
E. It 's possible to request the GC via methods in either java. Lang. Runtime or java.lang.System classes.
Answer:
C and E are correct. When an object has a reference variable, the reference variable lives inside the object, on the heap.
A is incorrect, because The order is different: First the object is collected. Then the object is finalized. B is incorrect-stack variables are not dealt with by the GC. D is incorrect because objects can live in "islands of isolation" and be GC eligible.
2. Which are valid declarations? (Choose all that apply.)
A. int $x;
B. int 123;
C. int _123;
D. int #dim;
E. int %percent;
F. int *divide;
G. int central_sales_region_Summer_2005_gross_sales;
Answer:
A, C, and G are legal identifiers.
B is incorrect because an identifier can't start with a digit. D, E, and F are incorrect because identifiers must start with $, _, or a letter.
3. Given:
1. class Maybe {
2. public static void main(String[] args) {
3. boolean b1 = true;
4. boolean b2 = false;
5. System.out.print(!false ^ false);
6. System.out.print(" " + (!b1 & (b2 = true)));
7. System.out.println(" " + (b2 ^ b1));
8. }
9. }
Which are true?
Seleccione al menos una respuesta.
a. Line 5 produces true.
b. Line 5 produces false.
c. Line 6 produces false.
d. Line 7 produces true.
e. Line 7 produces false.
f. Line 6 produces true.
Answer:
The exit is true false false. So A, C, E are true
4. class Fizz {
int x = 5;
public static void main(String args[]) {
final Fizz f1 = new Fizz();
Fizz f2 = new Fizz();
Fizz f3 = FizzSwitch(f1, f2);
System.out.println((f1 == f3) + " " + (f1.x == f3.x));
}
static Fizz FizzSwitch(Fizz x, Fizz y) {
final Fizz z = x;
z.x = 6;
return z;
}
}
Answer:
The outcome for the above code is
'true true'
The reason given in the book is:
"The references f1, z and f3 all refer to the same instance of Fizz. The final modifier assures that a reference variable cannot be referred to a different object but final doesnt keep the objects state from changing."
5. Given the following code:
public class OrtegorumFunction { public int computeDiscontinuous(int x) { int r = 1; r += X; if ((x > 4) && (x < 10)) { r += 2 * x; } else (x <= 4) { r += 3 * x; } else { r += 4 * x; } r += 5 * x; return r; } public static void main(String [] args) { OrtegorumFunction o = new OrtegorumFunction(); System.out.println("OF(11) is: " + o.computeDiscontinuous (11)); } }
What is the result?
a. OF(11) is: 45
b. OF(11) is: 56
c. OF(11) is: 89
d. OF(11) is: 111
e. Compilation fails.
f. An exception is thrown at runtime.
Answer:
E is correct. The if statement is illegal. The if-else-else must be changed to if-else if-else , which would result in OF (11) is: 111 .
6. Given:
.class Foozit {
. public static void main(String[] args) {
. Integer x = 0;
. Integer y = 0;
. for(Short z = 0; z < 5; z++)
. if((++x > 2) || (++y > 2))
. x++;
. System.out.println(x + " " + y);
. }
.}
What is the result?
Seleccione una respuesta.
a. 8 3
b. 8 1
c. 10 3
d. 8 2
e. 5 3
f. 10 2
g. 5 1
h. 5 2
Answer:
The good is D, we have to see that the second expression of the if only evaluates when the first is false.
7. class Titanic {
. public static void main(String[] args) {
. Boolean b1 = true;
. boolean b2 = false;
. boolean b3 = true;
. if((b1 & b2) | (b2 & b3) & b3)
. System.out.print("alpha ");
. if((b1 = false) | (b1 & b3) | (b1 | b2))
. System.out.print("beta ");
. }
.}
What is the result?
Seleccione una respuesta.
a. An exception is thrown at runtime.
b. No output is produced.
c. Compilation fails.
d. alpha beta
e. alpha
f. beta
Answer: B
8. Given:
1. class Comp2 {
2. public static void main(String[] args) {
3. float f1 = 2.3f;
4. float[][] f2 = {{42.0f}, {1.7f, 2.3f}, {2.6f, 2.7f}};
5. float[] f3 = {2.7f};
6. Long x = 42L;
7. // insert code here
8. System.out.println("true");
9. }
10. }
And the following five code fragments:
F1. if(f1 == f2)
F2. if(f1 == f2[2][1])
F3. if(x == f2[0][0])
F4. if(f1 == f2[1,1])
F5. if(f3 == f2[2])
What is true?
Seleccione una respuesta.
a. Three of them will compile, exactly three will be true.
b. Three of them will compile, only one will be true.
c. Three of them will compile, exactly two will be true.
d. Two of them will compile, two will be true.
e. Two of them will compile, only one will be true.
f. One of them will compile, only one will be true.
Answer: B
9. Given:
.class Sixties {
. public static void main(String[] args) {
. int x = 5; int y = 7;
. System.out.print(((y * 2) % x));
. System.out.print(" " + (y % x));
. }
.}
What is the result?
Seleccione una respuesta.
a. 2 1
b. 1 1
c. Compilation fails.
d. An exception is thrown at runtime.
e. 4 1
f. 1 2
g. 2 2
h. 4 2
Answer: H
10. Given:
.class Mixer {
. Mixer() { }
. Mixer(Mixer m) { m1 = m; }
. Mixer m1;
. public static void main(String[] args) {
. Mixer m2 = new Mixer();
. Mixer m3 = new Mixer(m2); m3.go();
. Mixer m4 = m3.m1; m4.go();
. Mixer m5 = m2.m1; m5.go();
. }
. void go() { System.out.print("hi "); }
.}
What is the result?
Seleccione una respuesta.
a. Compilation fails
b. hi
c. hi hi
d. hi hi hi
e. hi hi, followed by an exception
f. hi, followed by an exception
Answer: E
11. Given:
1. class Eco {
2. public static void main(String[] args) {
3. Eco e1 = new Eco();
4. Eco e2 = new Eco();
5. Eco e3 = new Eco();
6. e3.e = e2;
7. e1.e = e3;
8. e2 = null;
9. e3 = null;
10. e2.e = e1;
11. e1 = null;
12. }
13. Eco e;
14. }
At what point is only a single object eligible for GC?
Seleccione una respuesta.
a. After line 11 runs.
b. After line 10 runs.
c. After line 9 runs.
d. An exception is thrown at runtime.
e. After line 8 runs.
f. Compilation fails.
g. Never in this program.
Answer: D
12.
Given:
1. class Crivitch {
2. public static void main(String [] args) {
3. int x = 0;
4. // insert code here
5. do { } while (x++ < y);
6. System.out.println(x);
7. }
8. }
Which, inserted at line 4, produces the output 12?
Seleccione una respuesta.
a. int y = 12;
b. int y = x;
c. int y = 13;
d. int y = 10;
e. int y = 11;
f. None of the above will allow compilation to succeed.
Answer: E
13. Given:
.class Knowing {
. static final long tooth = 343L;
. static long doIt(long tooth) {
. System.out.print(++tooth + " ");
. return ++tooth;
. }
. public static void main(String[] args) {
. System.out.print(tooth + " ");
. final long tooth = 340L;
. new Knowing().doIt(tooth);
. System.out.println(tooth);
. }
.}
What is the result?
Seleccione una respuesta.
a. 343 340 340
b. 343 341 340
c. 343 341 343
d. Compilation fails.
e. 343 340 342
f. An exception is thrown at runtime.
g. 343 341 342
Answer: B
14. Given:
.class Feline {
. public static void main(String[] args) {
. Long x = 42L;
. Long y = 44L;
. System.out.print(" " + 7 + 2 + " ");
. System.out.print(foo() + x + 5 + " ");
. System.out.println(x + y + foo());
. }
. static String foo() { return "foo"; }
.}
What is the result?
Seleccione una respuesta.
a. 72 foo47 4244foo
b. 9 foo425 86foo
c. 9 foo47 86foo
d. 72 foo425 86foo
e. 72 foo47 86foo
f. Compilation fails.
g. 72 foo425 4244foo
h. 9 foo425 4244foo
i. 9 foo47 4244foo
Answer: D
15. Which are legal declarations? (Choose all that apply.)
Seleccione al menos una respuesta.
a. short [] y2 = [5];
b. short[5] x2;
c. short [] z [] [];
d. short z2 [5];
e. short [] y;
f. short x [];
Answer: C, E, F
5 oct 2012
[Cerrado] Consigue un reembolso o descuento indirecto comprando en amazon, simplemente usando estos links
tl;dr;
Si has comprado alguna vez en amazon puede que hayas intentado buscar algún cupón de descuento por webs o foros, como habrás comprobado no funcionan, sólo los que da amazon lo hacen.
Qué te puedo ofrecer?
Soy afiliado de amazon, promociono productos en otra web donde publico ofertas y comento productos que me parecen interesantes en Put in your basket. Como afiliado, por cada compra que se realice de uno de los productos que publicito, accediendo a amazon a través de los links de mi página, me dan alrededor de un 5% de cada compra. Des de hace un tiempo se me ocurrió que mis amigos compraran a través de mis links y nos repartimos lo que amazon me da por sus compras, por ahora la cosa ha funcionado bien, aunque debido al poco volumen de compras hasta que no llego al límite de pago pasan unos cuantas semanas, mis amigos no son demasiado compradores ;). Mi idea es que todo el mundo se pueda beneficiar de este pequeño descuento, algo es algo en estas épocas de crisis y cualquier euro extra se agradece. Puedes ver el detalle de los pagos en esta página, para que veas que mi intención es ser transparente y fiable al máximo.Qué gano yo?
Pues una parte de cada compra, tu te llevas un reembolso del 3.5% de cada una de tus compras, o lo que es lo mismo, el 65% de lo que me de amazon por tu pedido. El resto será un pequeño pago para mantener y mejorar la web, mi intención no es hacer negocio con este método sino hacer posible que el máximo número de gente pueda aprovechar dicho descuento. En un futuro si la cosa funciona aumentaré el ratio para que tengas un mayor descuento, también tengo la idea de que la gente colabore y me envie artículos por los cuales puedan ganar dinero, hay que dedicar mucho tiempo que ahora no tengo, veremos como va la cosa.Qué tienes que hacer para conseguir este reembolso?
Paso 1. Haz las compras en amazon a través de uno de estos links
Según el país donde quieras comprar, recuerda que si eres de España y gastas más de 30€ en amazon.co.uk el envío es gratuito.Si alguien pide enlace para otro país miraré de ponerlo.
Paso 2. Reclama tu pago
Una vez que tu pedido haya llegado y estés seguro de no devolver nada, contacta conmigo a través del perfil de google+ con toda la información posible para que pueda validar tu pedido, amazon solo me da una pequeña parte de información por privacidad de los usuarios. También debes facilitar una cuenta de Paypal para que pueda realizar el pago una vez que amazon me abone la comisión por tu compra, cuando amazon me pague, transferiré el 65% de lo que gane por tu pedido a tu cuenta de Paypal.Garantías
Qué garantía te puedo ofrecer? Ninguna, lo siento. Si amazon no me paga no conseguirás tu reembolso y si no puedes justificar tu compra tampoco. Iré con cuidado los primeros días, no sea que alguien aproveche para timarme. Recuerda que mi intención solo es compartir este pequeño beneficio con buena fe, tendrás que confiar en mi. I como último punto, si amazon decide que esta actividad no es lícita, lo dejaré de inmediato, o sea que más vale que seas rápido por si acaso.Un saludo
20 mar 2012
Mejora tu CV con estas ideas y consigue un empleo mejor
- Puntos fuertes y débiles: Actitudes y aptitudes que puedes aprovechar mejor en tu trabajo, deberás ser muy crítico contigo mismo para identificar cuáles son. Por ejemplo:
- Multilingüe: Castellano, Inglés, Catalán y Portugués, con excelente nivel de comunicación verbal y escrita en todos estos idiomas. Portugués sólo a nivel de conversación y lectura.
- Sólida experiencia en Atención al Cliente y amplios conocimientos en diversas áreas administrativas entre ellas: gestión de pedidos, logística, almacén, incidencias, crédito, impagados y proveedores.
- X años como director financiero de una compañía con ventas anuales de $ X millones en promedio, €X millones el año pasado.
- Creativo y con muchos recursos para innovar y resolver problemas. Habilidad para desarrollar ideas consistentes y nuevos conceptos.
- Gran capacidad comunicativa con clientes y miembros de la compañía, sobresaliente gestión de problemas.
- Habilidades para manejar múltiples tareas bajo grandes presiones. Mucha dedicación y motivación hacia el trabajo en equipo.
- De aprendizaje rápido, excelente ética de trabajo y gran versatilidad y adaptabilidad para afrontar cambios y problemas.
- Excelente manejo de sistemas informáticos en ambiente SAP y Oracle, bajo todas las plataformas.
- Éxitos y derrotas: Anota todo lo que has conseguido en tu vida personal y/o en el trabajo sea bueno o malo.
- Aumenté las ventas en un 20% como líder principal del equipo de marketing.
- Como director de un proyecto de ingeniería logré un aumento de €4.5 millones en las ganancias para el último año.
- Desperté el espíritu de unidad del personal a través de un programa de incentivos de seis meses que también condujo a un importante aumento en las ventas.
- He recibido el galardón de "Empleado del Año" durante dos años consecutivos.Brindé asesoramiento técnico a 19 alumnos del programa de formación de la empresa.
- Tus objetivos: tus metas a corto, mediano y largo plazo, tanto en lo laboral como en lo personal
- Aspectos que puedes mejorar: una recapitulación de todo lo que piensas es factible de mejora, para esta tarea pide ayuda a un tercero.
- Experiencias: que te han ayudado a desarrollar habilidades y/o resolver problemas como: trabajos en el extranjero, responsabilidades en la universidad, voluntariado en alguna ONG, etc.
- Puesto que buscas: y que crees es el ideal para ti. El nivel de responsabilidad incluyendo si quieres trabajar sólo o en equipo.
- Lo que te ha gustado de tu puesto anterior y cuales funciones o tareas no quieres volver a enfrentar.
- Razones por las que deseas cambiar de empleo, si fuere el caso. ¿Cómo está tu valor de empleado frente al valor del mercado?