quais as duvidas alternativas abaixo pois estou em duvida
Which of the following statements about StringBuilder true ?
Select any 2 options :
a) It has inherent thread protection
b) It is faster than StringBuffer
c) It defines the append and insert methods
d) It is immutable
tenho seguinte arquivo a.txt
contendo
exemplo.
mais.
um.
e fiz um java abaixo mas não mostra o conteudo o que
está errado
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
//InputStream input = InputStream(new File(TestaScanner.class.getResourceAsStream("a.txt")));
Scanner scanner= new Scanner(new File("D:\\workspace_patt\\cert\\bin\\br\\com\\cert\\WhizLabs2\\a.txt"));
scanner.useDelimiter(".");
while(scanner.hasNext())
System.out.println( scanner.next());
scanner.close();
}catch (FileNotFoundException e){
e.printStackTrace();
}
}
}
------------------------------------
outra duvida referente ao switch
quando uso numero e sem break passa uma vez só
e quando uso caracter mostra o que achou eo default
--exemplo 1
public static void main(String[] args) {
// TODO Auto-generated method stub
Ex14 t = new Ex14();
for(int i=0;i<4;i++){
System.out.println(t.f(i));
}
}
String f(int i){
switch(i){
case 0: return "A";
case 1: return "B";
case 2: return "C";
default :return "D";
}
}
}
------------
exemplo 2
enum Grade{A{public String toString(){return "Book";}},B,C,D}
public class Ex15 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Grade grade = Grade.A;
switch (grade){
case A :
System.out.println(grade);
case B :
System.out.println("B");
default :
System.out.println("default");
}
}
}
essa não entendi ???
which og following statements about the implementation of the hashCode() method of Object class as shown in the following
code is true???
public class Ex21 {
private int number;
public Ex21 (int i){
number=i;
}
public int hashCode(){
int i=(int)(Math.random()*100);
return i*number;
}
//others methods
}
---
a) the code implements hashcode() method correcty
b) the code does not implement hashcode() method correcty
c) this implementation of hashcode() method is correct only if the equals () methods is not overriden
d) the given code does not contain enough information to coment on the correctness of the hashcode()
e) none the these
gostaria de saber se o que respondi está correto :
which of the following statements regarding the java.util.Set interface are true?
seelct any 3 options :
a) java.util.Set extends the java.util.Collection interface
b) java.util.Set maintains a set of key-value pairs
c) java.util.Set does not allow duplicate elements.
d) java.util.Set maintains its elements in a sorted order.
e) All methods definded in java.util.Set are also define in java.util.Collection
f) java.util.Set does not allow a null element