Professional Documents
Culture Documents
Conceptos Importantes Examen Java
Conceptos Importantes Examen Java
Point 1)
The code below is executed by "java -Dmyprop=myprop Test". Which two, placed instead of "//some code goes here", will
produce the output "myprop"? (Choose two)
public class Test {
public static void main(String args[]) {
String prop = //some code goes here//
System.out.print(prop);
}
}
A) System.getEnv("myprop");
B) System.load("myprop");
C) System.property("myprop");
D) System.getProperty("myprop");
E) System.get("myprop");
F) System.getProperties().getProperty("myprop");
Answers: D, F
System.getProperty functions gets the system property indicated by the specified key.
Point 2)
Always Remember
A Static method can call other Static Methods in same class
A Static method can not call other Non Static Methods directly in same class
A Non Static Method can call static method directly
Point 3)
public class Room {
public int roomNr;
private Date beginDtm;
private Date endDttm;