Test
Simulador de preparacion exmen certificacion JAVA 7 developer
Preguntas del test (53)
1what are the valid components of a java source file (choose all that apply)
- Apackage statement
- Bimport statements
- Cmethods
- Dvariables
- Ejava compiler
- Fjava runtime environment
2the following munbered list of java class components is not in any particular order. select the correct order of their occurrence in a java class (choose all that apply):
1. comments
2. import statements
3. package statement
4. methods
5. class declaration
6. variables.- A1,3,2,5,6,4
- B3,1,2,5,4,6
- C3,2,1,4,5,6
- D3,2,1,5,6,4
3which of the following examples define the correct java class structure
- A

- B

- C

- D

- E

- F

- A
4given the following definition of the class EjavaGuru,
what is the output of the previous class, if it is executed using the command:
"java EjavaGuru one two three four"
- Aone:two:three
- BEJavaGuru:one:tow
- Cjava:EJavaGuru:one
- Dtow:three:four
5given the following contents of the java source code file MyClass.java select the correct options

- Athe imported class, java.util.Date, can be accessed only in the class Student.
- Bthe imported class, java.util.Date, can be accessed by both the Student and Course classes
- CBoth of the classes Student and Course are defined in the package com.ejavaguru.
- DCourse is defined in the default java package.
6which of the following options, when inserted at //INSERT CODE HERE will print out EJavaGuru
- Apublic void main (String [] args)
- Bpublic void main (String args [] )
- Cstatic public void main (String[] array)
- Dpublic static void main (String args)
- Estatic public main (String args[])
7select the correct options
- Ayou can start the execution of a java application through the main method
- Bthe java compiler calls and executes the main method
- Cthe java virtual machine calls and executes the main method
- Da class calls and executes the main method
8A class Course is definided in a package com.ejavaguru. Given that the physical location of the corresponding class file is /mycode/com/ejavaguru/Course.class and execution takes place within the mycode directory, which of the following lines of code, when inserted //INSERT CODE HERE, will import the Course class into the class MyCourse

- Aimport mycode.com.ejavaguru.Course;
- Bimport com.ejavaguru.Course;
- Cimport mycode.com.ejavaguru;
- Dimport com.ejavaguru;
- Eimport mycode.com.ejavaguru.*;
- Fimport com.ejavaguru.*;
9examine the following code:
which of the following statements will be true if the variable courseName is defined as a private variable?
- Aclass EJavaGuru will print Java
- Bclass EJavaGuru will print null
- Cclass EJavaGuru will won't compile
- Dclass EJavaGuru will throw an exception at runtime
10Given the following definition of the class Course:
what's the output of the following code?
- Athe class EJavaGuru will print java
- Bthe class EJavaGuru will print null
- Cthe class EJavaGuru will not compile
- Dthe class EJavaGuru will throw an exception at runtime
11Given the following code, select the correct options

- Ayou can't define a method argument as a private variable
- Ba method argument should be defined with either public or default accessibility
- Cfor overridden methods, method arguments should be defined with protected accessibility.
- Dnone of the above
12Select all incorrect statements
- Aa programmer can't define a new primitive data type
- Ba programmer can define a new primitive data type
- Conce assigned, the value of a primitive can't be modified
- Da value can't be assigned to a primitive variable
13which of the options are correct for the following code?

- Acode at line 4 fails to compile
- Bcode at line 5 fails to compile
- Ccode at line 6 fails to compile
- Dcode at line 7 fails to compile
14what is the output of the following code?

- A611
- B641
- C930
- D960
15Select the options that is / are the best choice for de following

- Along, boolean, double
- Blong, int, float
- Cchar, int, double
- Dlong, boolean, float
16which of the following options contain correct code to declare and initialize variables to store numbers?
- Abit a = 0;
- Binteger a2 = 7;
- Clong a3 =0X10C;
- Dshort a4 = 0512;
- Edouble a5 = 10;
- Fbyte a7 = -0;
- Glong a8 = 123456789;
17Select the options that, when inserted at //INSERTE CODE HERE, will make the following code output code a value of 11

- Actr +=1;
- Bctr =+1;
- C++ctr;
- Dctr = 1;
18what is the output of the following code

- A218
- B232
- C246
- Dcompilation error
19what is true about the following lines of code

- Acode prints true
- Bcode prints false
- Ccode prints >= false
- Dcompilation error
20which of the following methods correctly accepts three whole numbers as methods arguments and returns their sum as a decimal number?
- A

- B

- C

- D

- A
21how can you include encapsulation in your class design
- Adefine instance variables as private members
- Bdefine public methods to access and modify the instance variables
- Cdefine some of the instance variables as public members
- Dall of the previous
22if the functionality of the operators = and > were to be swapped in java (for the code on line number 4, 5, and 6), what would be the result of the following code?

- Atrue, true, false
- B10.0, false, false
- Cfalse, false, false
- Dcompilation error
23examine the following code and select the correct options

- Acode prints false
- Bcode prints true
- Ca code will print true if code on line 6 is modified to the following

- Dcode will print true if code on line 6 is modified to the following

24examine the following code and select the correct options

- Athe heigth de a Person can never be set to more than 300.
- Bthe previous code is an example of a well-encapsulated class
- Cthe class would be better encapsulated if the heigth validation weren't set to 300.
- Deven though the class isn't well encapsulated, it can be inherited by other classes
25which of the following correctly accepts three whole numbers as method arguments and returns their sum as a decimal number?
- A

- B

- C

- D

- A
26which of the following statements are true?
- Aif the return type of a method is int, the method can return a value od type byte
- Ba method may or may not return a value
- Cif the return type of a method is void, it can define a return statement without a value, as follows: "return;"
- Da method may or may not accept any method arguments.
- Ea method should accept at least one method argument or define its return type.
- Fa method whose return type is String can't return null
27Given the following definition of class Person,

- AanotherMethod, anotherMethod, someMethod, someMethod
- BanotherMethod, EJava, someMethod, someMethod
- CanotherMethod, EJava, someMethod, EJava
- DCompilation error.
28what is the ouput of the following code?

- A20
10
11
11 - B20
20
11
10 - C20
10
11
10 - Dcompilation error
- A20
29Given the following signature of method eJava, choose the options that correctly overload this method

- Aprivate String eJava(int val, String firstName, double dur)
- Bpublic void eJava(int val1, String val2, double val3)
- CString eJava(int name , String age, double duration)
- Dfloat eJava(double name, String age, byte duration)
- EArrayList<String> eJava()
- Fchar[] eJava(double numbers)
- GString eJava()
30given the following code,

- ACompilation error
- BRintime exception
- Cint
String - Dlong
Object
31examine the following code and select the correct options:

- AThe class EJava defines three overloaded contructors
- BThe class Ejava define two overloaded contructors. The private constructor isn't counted as an overloaded constructor.
- CConstructors with different access modifiers can't call each other
- Dthe code prints the following:
protected
private
public - Ethe code prints the following:
public
private
protected
32Select the incorrect options
- AIf a user defines a private constructor for a public class, Java creates a public default constructor for the class.
- BA class that gets a default constructor doesn’t have overloaded constructors.
- CA user can overload the default constructor of a class.
- DThe following class is eligible for default constructor:
class EJava {} - EThe following class is also eligible for a default constructor:
class EJava {
void EJava() {}
}
33What is the output of the following code?

- A4c010
- B4c10
- C113
- D103
- ECompilation error
34What is the output of the following code?

- A0:0
- Ba:b
- C0:b
- Da:0
- Ecompilation error
35Which of the following are valid lines of code to define a multidimensional
int array?- Aint[][] array1 = {{1, 2, 3}, {}, {1, 2,3, 4, 5}};
- Bint[][] array2 = new array() {{1, 2, 3}, {}, {1, 2,3, 4, 5}};
- Cint[][] array3 = {1, 2, 3}, {0}, {1, 2,3, 4, 5};
- Dint[][] array5 = new int[2][];
36Which of the following statements are correct?
- ABy default, an ArrayList creates an array with an initial size of 16 to store its elements.
- BBecause ArrayList stores only objects, you can’t pass element of an ArrayList to a switch construct.
- CCalling clear() or remove() on an ArrayList, will remove all its elements.
- DIf you frequently add elements to an ArrayList, specifying a larger capacity will improve the code efficiency.
- ECalling the method clone() on an ArrayList creates its shallow copy; that is, it doesn’t clone the individual list elements.
37Which of the following statements are correct?
- AAn ArrayList offers a resizable array, which is easily managed using the methods it provides. You can add and remove elements from an ArrayList.
- BValues stored by an ArrayList can be modified.
- CYou can iterate through elements of an ArrayList using a for loop, Iterator, or ListIterator.
- DAn ArrayList requires you to specify the total elements before you can store any elements in it.
- EAn ArrayList can store any type of object.
38What is the output of the following code?

- ALine 7 prints true
- BLine 7 prints false
- CLine 8 prints -1
- DLine 8 prints 1
- ELine 9 removes all elements of the list ejg
- FLine 9 sets ejg to null
- GLine 10 prints null
- HLine 10 prints []
- ILine 10 prints a value similar to ArrayList@16356
- JLine 11 throws an exception
39What is the output of the following code?

- Atrue printed once
- Bfalse printed once
- Ctrue printed in an infinite loop
- Dfalse printed in an infinite loop
40What is the output of the following code?

- AgZmeAZ
- BgZmeAa
- CgZm
- DgZ
- Egame
41What is the output of the following code?

- AgZmeAZ
- BgZmeAa
- CgZm
- DgZ
- Egame
42What is the output of the following code?

- A12S512S5
- B12S12S
- C1025102S
- DdRuntime exception
43What is the output of the following code?

- A521
- BRuntime exception
- C65321
- D65431
44What’s the output of the following code?

- A10
- B30
- C31
- D32
45What’s the output of the following code?

- A10
- B30
- C31
- D32
46Which of the following statements is true?
- AThe enhanced for loop can’t be used within a regular for loop.
- BThe enhanced for loop can’t be used within a while loop.
- CThe enhanced for loop can be used within a do-while loop.
- DThe enhanced for loop can’t be used within a switch construct.
- EAll of the above statements are false.
47What’s the output of the following code?

- Atrue
false
ABC - Bfalse
ABC - Ctrue
ABC - DCompilation error
- Atrue
48Given the following code, which of the following lines of code can individually replace the //INSERT CODE HERE line so that the code compiles successfully?

- Acase 10*3: System.out.println(2);
- Bcase num: System.out.println(3);
- Ccase 10/3: System.out.println(4);
- Dcase num2: System.out.println(5);
49What’s the output of the following code?

- Adefault
- Bdefault
4 - C4
- DCompilation error
50What’s the output of the following code?

- Adefault
case1
case2 - Bcase1
case2 - Ccase2
- DCompilation error
- ERuntime exception
- Adefault
51What’s the output of the following code?

- Aejava
enum
guru - Bejava
- Cejavaguru
e - Dejava
enum
guru
ejavaguru
- Aejava
52What’s the output of the following code?

- Aelse
- B0
1
2 - C0
1 - DCompilation error
53What’s the output of the following code?

- ACompilation error
- B0
5 - C0
5
10 - D10
- E0
1
5 - F5
Información
- Descripción
- se trata de hacer un examen para prepararse para el examen de certificacion de java
- Autor
- JUAN JOSÈ ORJUEL
- Idioma
- Español
- Visitas
- 274
- Etiquetas
- Valoración
- Aún sin valoraciones Valora este test