Examen de java certification



Comments



Description

Examen: 1Z0-803 Oracle Certified Associate, Java SE 7 ProgrammerExamen 1 de 10. Calificación Global: 38.0% No. 1 2 3 4 5 6 7 8 Objetivo de certificación Using Operators and Decision Constructs Creating and Using Arrays Using Loop Constructs Working with Methods and Encapsulation Working with Inheritance Handling Exceptions Java Basics Working With Java Data Types Porcentaje obtenido 0.0% 17.0% 0.0% 73.0% 38.0% 67.0% 33.0% 50.0% Objective 1: Using Operators and Decision Constructs Use Java operators Use parenthesis to override operator precedence Test equality between Strings and other objects using == and equals () Create if and if/else constructs Use a switch statement Objective 2: Creating and Using Arrays Declare, instantiate, initialize and use a one-dimensional array Declare, instantiate, initialize and use multi-dimensional array Declare and use an ArrayList Objective 3: Using Loop Constructs Página 1 de 17 Create and use while loops Create and use for loops including the enhanced for loop Create and use do/while loops Compare loop constructs Use break and continue Objective 4: Working with Methods and Encapsulation Create methods with arguments and return values Apply the static keyword to methods and fields Create an overloaded method Differentiate between default and user defined constructors Create and overload constructors Apply access modifiers Apply encapsulation principles to a class Determine the effect upon object references and primitive values when they are passed into methods that change the values Objective 5: Working with Inheritance Implement inheritance Develop code that demonstrates the use of polymorphism Differentiate between the type of a reference and the type of an object Determine when casting is necessary Use super and this to access objects and constructors Use abstract classes and interfaces Objective 6: Handling Exceptions Differentiate among checked exceptions. RuntimeExceptions and Errors Create a try-catch block and determine how exceptions alter normal program flow Describe what Exceptions are used for in Java Invoke a method that throws an exception Recognize common exception classes and categories Objective 7: Java Basics Define the scope of variables Define the structure of a Java class Create executable Java applications with a main method Import other Java packages to make them accessible in your code Objective 8: Página 2 de 17 . te enlistamos las preguntas que fueron mal contestadas en este ejercicio de simulador: Question 1 Which of the following statements are true? A..out. public String major = "Undeclared".public Class Pants Question 3 public class Student{ public String name = "". public int age = 0.. public boolean fulltime = true. public void display(){ System.... "dereference" and garbage collection) Call methods on objects Manipulate data using the StringBuilder class and its methods Creating and manipulating Strings A modo de retroalimentación. Question 2 Select the class declaration that adheres to the class-naming guidelines.An attribute cannot be a reference to another object..public Class 501Pants C.. } public boolean ifFullTime(){ return fulltime. B..An object and a class are exactly the same. B.public Shirt D. } } Which line of code initializes a student instance? A..An object is an instance of a class.class Shirt B. A.Working With Java Data Types Declare and initialize variables Differentiate between object reference variables and primitive variables Read or write to object fields Explain an Object's Lifecycle (creation..An class is a blueprint for a object. Página 3 de 17 . D.Student student1 = Student.new(). C.Student student1.println("Name: "+name + "Major: "+major). .The third argument is given the value null.out..println(args[1]).}} class Fred1 { D.Student student1 = Student().public static void main (String [] args) { System..The third argument is given the value zero.. Question 6 Which two will compile. } } What is the result? A..println (args [1]). C.C.} void print () { System.default C. X(String s) { str = s. (Choose two) class Fred1{ A.out.out. Question 4 Given: class X { String str = "default". and can be run successfully using the command: java Fred1 hello walls..out.Compilation fails D...public static void main (String [] args) { System. E. D.println (args)..}} class Fred1{ B.The third argument is given the appropriate false value for its declared type..The program prints nothing Question 5 A method is declared to take three arguments.Compilation fails.println(str).println(args[2]). B.hello B. What is the result? A.}} Página 4 de 17 . A program calls this method and passes only two arguments. D.Student student1 = new Student().public static void main (String args) { System..}} class Fred1 { C.The third argument is given the value void..public static void main (String [] args) { System.print()..out. } public static void main(String[] args) { new X("hello")... B..Question 7 Consider the following program: class Point2D { private int x. item = new Thing(). D. public Point2D(int x.One reference variables are created...Three objects are created. ref= item. B.out..[10.point B.. 0] E.A method is an attribute defining the property of a particular abstraction.Point C... A. C.[0.ref. } public String toString() { return "[" + x + ". } } Which one of the following options provides the output of this program when executed? A... 20). " + y + "]". Thing entity = new Thing(). C. 20] Question 8 Which statement is true about a method? A. how many objects and how many references variables are created by the following code? (Choose two) Thing item. } public static void main(String []args) { Point2D point = new Point2D(10. int y) { x = x.A method is a implementation of an abstraction.. Página 5 de 17 .Two objects are created.[10.A method is a blueprint for making operations. Question 9 Given that Thing is a class. System..five object is created..A method is a category of objects.. y. var=ref. 0] D.var. D.println(point). stuff. 2.Two reference variable. F. 6. 4.0 % 6 + 7 . 5. 2.public void main (String[] args) B. 5.0 Página 6 de 17 . 4.final public main (String args[]) F..-2.9. 6.out. 6 C. 5.3. 1.public static void main (String args) E. 4 B. 3.public void main(String args[]) C.none apply Question 12 Given: public static void main(String[] args) { double a = 2 + 5 * 6 / 7. 1....Five reference variables are created.. when inserted at //INSERT CODE HERE..E. will print out EJavaGuru? public class EJavaGuru { // INSERT CODE HERE { System.out. 2. } What is the result? A. 5... 1..static public void main (String[] array) D. 2. } } A. Select the correct order of their occurrence in a Java class (choose all that apply): 1 comments 2 import statement 3 package statement 4 methods 5 class declaration 6 variables A.... 4 Question 11 Which of the following options. Question 10 The following numbered list of Java class components is not in any particular order..3.1. 6 D.println("EJavaGuru").println(a).3. System. for (int i = 0. c... } System.... c=100.j--) { do { suma += i * j % z + 3... Question 15 Given: public class SuperLoop3 { public static void main(String[] args) { int suma = 0.2857 D..int a.println("suma:: " + suma).a$_123 Question 14 Which of the following are valid declarations: A.2Next D..4.int123 C. j = 9. D. a = b = c = 100.num B.int a=100. i++.suma:: 20 D.. c. B.suma:: 14 C._interface E.30. --j.suma:: 22 B. b....0 C.compilation fails Página 7 de 17 .int a = b = c = 100...int a= 100 = b = c. } while (z++ <= 1).. } } What is the result? A. b.compilation fails Question 13 Which of the following is/are illegal Java identifier(s)? A.B. i < 4 && j > 0.int a. b. E..out. z = 1. C. Line 4 Question 17 not static member.out. a constant or a method..Line 2 C..//line 2 System.//line 3 System.6) / 8 .//line 4 } } What line of code shows the greatest value? A.. Question 18 class Test{ public static void main(String[] args) { int var=3.println((27 * 9 + 5 . }catch(RuntimeException e){ e.. B.can be a variable. //line 1 System. D..is same as a local variable.printStackTrace()..7 ..out. } case 2: try{ Página 8 de 17 .Question 16 Given class TestA { public static void main(String[] args) { System. } default: try{ throw new ArrayIndexOutOfBoundsException().out. }catch(RuntimeException e){ e. switch (var) { case 1: try{ throw new IllegalArgumentException().Line 3 D.(Choose two) A.println(4 * 7 / 7 + 9 + 36 / 9 * 2 + 10).5 + 9 / 3 + 15 /15 ..belongs to an instance of the class.Line 1 B. C.out.println(33 / 11 * 9 .belongs to the class.1)..2 .6 + 40) / 8 ..println(((3 * 2) * (5 + 9 .6 + 27 / 3) * 15).5 + 7 * 4 / 2).printStackTrace(). boolean j = (1 < 5).main C.java. D.main D.lang.Test.main B.bar.641 C..printStackTrace(). B.lang.main at com. } } } } java..Test.Test.(2 + 4) * (3 .ArrayIndexOutOfBoundsException at com.out. long b = 20.boolean h = 1.7 B..611 B.Test.ArrayIndexOutOfBoundsException at com.bar.java.bar.compilation fails Question 19 Which declaration initializes a boolean variable? A. C. }catch(RuntimeException e){ e.bar.. } } What is the result? A.ArithmeticException at com.960 Question 21 Which of the following expressions will evaluate to 7?(Choose two) A..throw new ArithmeticException().ArithmeticException at com.2 + 4 * 3.930 D..lang.7) Página 9 de 17 .... short c = 30.lang.boolean m = null.java.. System.. Question 20 Given: public class Foo { public static void main(String[] args) { int a = 10.println(++a + b++ * c).boolean k = 0..main and A.bar.Test.. out. when inserted at // INSERT CODE HERE.false false D. } What is the result ? true true false B.println(res == res2)..println(i >= b).out.- Question 23 Select the options that.equals(res2)).false true C.((2 + 4) * 3) . will make the following code output a value of 11: public class IncrementNum { public static void main(String[] args) { int ctr = 50.. System. String res2 = "Hola".++ctr.2 + (4 * 3) ..true A. D. System.out.println(ctr % 20). // INSERT CODE HERE System.out..25) Question 22 Given: public static void main(String[] args) { String[] msg = {"H". "o".ctr += 1.ctr =+ 1. } } A. C.7 D.ctr = 1. Question 24 What is true about the following lines of code? boolean b = false.. "l"..println(res.C. Página 10 de 17 . System. "a"}. String res =msg[0]+msg[1]+msg[2]+msg[3]. int i = 90. B. i: 4.out. j: 12 i: 2. } } What is the output? A. System..println("S:"+s1).S:123 B. j: 10 B... j: 0 i: 6. j--) { System... i++) { for (int j = 15.Code prints 90 >= false D..A.Code prints false C. j: " + (j -= 3))..Compilation fail Question 26 Given the code fragment: public class Bucle { public static void main(String[] args) { for (int i = 0.. j++. j: 12 i: 2.replace("321"). s1=s1.. i <= 2. j: 3 i: 5.i: 3. } } } } What is the result? i: 1.out.S:12321 D. j >= 0..S:321 C.Code prints true B. j: 9 i: 3.Compilation error Question 25 Given: class Test{ public static void main(String args[]) { String s1 = new String("123").S:123321 E. j: 6 A. j: -3 i: 1.println(" i: " + (++i) + ". j: 7 Página 11 de 17 . println("suma:: "+suma)..suma::65 D. j: 1 i: 6. i < 4 && j>7.suma::100 Question 28 Which three are valid types for switch?(Choose three) A.Compilation fails Question 27 Given: public class SuperLoop { public static void main(String[] args) { int suma=0.suma:: 99 B..double D..float C.out. while(j++<11).Float Question 29 Given: public class Point2D { private int x..i: 4.i: 2. j: 12 C.. j: 4 i: 5. j: 12 D. while(z++<1)..i: 2.int B.j=9.compilation fails C. j: 9 i: 1.. y. i++.String F..j--) do do suma+=i+j+z.. for (int i = 0..z=0. System. j: 10 E... j: -2 i: 1. } } What is the result? A. Página 12 de 17 .Integer E. case "diamond": System. "diamond".print(" heart "). default: System.println(point). 0] D.Point C.print(" club ")..point B..print(" spade ").. } } Which one of the following options provides the output of this program when executed? A.club none none none C. " + y + "]".none none none none B.x = x. case "spade": System.out. case "hearts": System. break.. "spade".club spade diamond none E.out. } public static void main(String[] args) { Point2D point = new Point2D(10... 20). 0] E. break.out.out. } } Which one of the following options shows the output of this program? A.out.. } public String toString() { return "[" + x + ". y=y. break..public Point2D(int x.. 20] Question 30 String[] cards = { "Club".print(" diamond ").[10. System.out..print(" none "). int y) { this.club spade diamond heart Página 13 de 17 . for (String card : cards) { switch (card) { case "Club": System.[0.[10. "hearts" }.club spade none none D. break. out.getClass()...1 2 0 1 2 D.out. while (ii < table.. "cc"}. System.Compilation fails Question 33 Página 14 de 17 . What is the result? A.2false3 D. {3.print (array2D[0].println(ii++).print(array2D[1]. } } What is the result? A.isArray() + "")..3false1 B... 2}. 6}}. 4. System..length) System.length+ "" ).length).0 0 B..2true3 C. "bb". do while (ii < table..2false1 Question 32 Given: public class DoCompare4 { public static void main(String[] args) { String[] table = {"aa". 1.out.2true1 G.Question 31 int [] [] array2D = {{0..out.1 2 0 1 2 0 C.3true1 E.3false3 F. 5. int ii =0.println (array2D[0][1]).. System. /* Line 8 */ } public void tellItLikeItIs() { System.PI * radius * radius. /* Line 5 */ tellIt. public Circle (double r) { radius = r.4).Given: public class Circle { double radius.area field. What three modifications are necessary to ensure that the class is being properly encapsulated?(Choose three) A Change the access modifier of the radius to private .tellItLikeItIs().getRadius().} public double getRadius() {return radius. } } This class is poorly encapsulated. c1. } C When the radius is set in the Circle constructor and the setRadius () method.tellItLikeItIs(). recomputed the area and store it into the .out.PI * c1.getRadius() * c1.Change the getArea () method: B.area = Math. /* Line 3 */ Tell tellIt = new Tell(). . You need to change the circle class to compute and return the area instead.. /* Line 7 */ ((Truth) tellIt).tellItLikeItIs().public double getArea () { return area. Change the getRadius () method: public double getRadius () { D area = Math. public double area.} public double getArea() { return /* ??? */. /* Line 6 */ ((Truth) tellIt). /* Line 4 */ speakIT. } } class Tell extends Speak implements Truth { Página 15 de 17 .} } class App { public static void main(String[] args) { Circle c1 = new Circle(17. } Question 34 class Speak { /* Line 1 */ public static void main(String[] args) { /* Line 2 */ Speak speakIT = new Speak().} public void setRadius(double r) { radius = r.tellItLikeItIs().println("Right off!").return radius. two ().Line 7 D.out.println("Right on!").abstract int var1 = 89.@Override public void tellItLikeItIs() { System.} public static void main (String [] args) { new Y(). } } What changes will make this code compile? Página 16 de 17 .. } } interface Truth { public void tellItLikeItIs().Line 5 B..Line 8 Question 35 Which code fragment is illegal? class Base1 { A.abstract class Abs1 { } } abstract class Abs1 { B.abstract class Abs1 extends Basel {} } D... } Which three lines will compile and output “right on!”?(Choose three) A. Question 36 Given a java source file: class x { x () {} private void one () {} } public class Y extends x { Y () {} private void two () {one()..void doit () { } } class Basel { C..Line 6 C. A.adding the public modifier to the declaration of class x B.removing the private modifier from the two () method Página 17 de 17 .changing the private modifier on the declaration of the one() method to protected D.....removing the Y () constructor E..adding the protected modifier to the x() constructor C.
Copyright © 2024 DOKUMEN.SITE Inc.