A continuación tienes las preguntas relacionadas con este capítulo del curso.
Cuestionario 11. 1Z0-808
Cuestionario Summary
0 de 3 preguntas completadas
Preguntas:
Información
You have already completed the cuestionario before. Hence you can not start it again.
Cuestionario is loading…
You must sign in or sign up to start the cuestionario.
En primer lugar debes completar esto:
Resultados
Resultados
0 of 3 questions answered correctly
Your time:
El tiempo ha pasado
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categorías
- Sin categorizar 0%
- 1
- 2
- 3
- Current
- Revisar
- Respondido/a
- Correcto
- Incorrecto
- Pregunta 1 de 3
1. Pregunta
Given the following two classes:
Customer.java public class Customer { ElectricAccount acct = new ElectricAccount(); public void useElectricity(double kWh) { acct.addKWh(kWh); } }
==================================================
ElectricAccount.java public class ElectricAccount { private double kWh; private double rate = 0.07; private double bill; // line n1 }
How should you write methods in the ElectricAccount class at line n1 so that the member variable bill is always equal to the value of the member variable kwh multiplied by the member variable rate?
Any amount of electricity used by a customer (represented by an instance of the customer class) must contribute to the customer’s bill (represented by the member variable bill) through the method useElectricity method. An instance of the customer class should never be able to tamper with or decrease the value of the member variable bill.
CorrectoIncorrecto - Pregunta 2 de 3
2. Pregunta
Given the code fragments:
Person.java public class Person { String name; int age; public Person(String n, int a) { name = n; age = a; } public String getName() { return name; } public int getAge() { return age; } }
======================================
Test.java public class Test { public static void checkAge(List
list, Predicate predicate) { for (Person p : list) { if (predicate.test(p)) { System.out.println(p.name + " "); } } } public static void main(String[] args) { List iList = Arrays.asList(new Person("Hank", 45), new Person("Charlie", 40), new Person("Smith", 38)); // line n1 } } Which code fragment, when inserted at line n1, enables the code to print Hank?
CorrectoIncorrecto - Pregunta 3 de 3
3. Pregunta
Given the code fragment:
public static void main(final String[] args) throws Exception { String[][] arr = {{"A", "B", "C"}, {"D", "E"}}; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { System.out.print(arr[i][j] + " "); if (arr[i][j].equals("B")) { break; } } continue; } }
What is the result?
CorrectoIncorrecto