MCQOPTIONS
Saved Bookmarks
This section includes 10 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How to read a classpath file? |
| A. | InputStream in = this.getClass().getResource(“SomeTextFile.txt”); |
| B. | InputStream in = this.getClass().getResourceClasspath(“SomeTextFile.txt”); |
| C. | InputStream in = this.getClass().getResourceAsStream(“SomeTextFile.txt”); |
| D. | InputStream in = this.getClass().getResource(“classpath:/SomeTextFile.txt”); |
| Answer» D. InputStream in = this.getClass().getResource(“classpath:/SomeTextFile.txt”); | |
| 2. |
Which environment variable is used to set java path? |
| A. | JAVA |
| B. | JAVA_HOME |
| C. | CLASSPATH |
| D. | MAVEN_HOME |
| Answer» C. CLASSPATH | |
| 3. |
How to use environment properties in the class? |
| A. | @Environment |
| B. | @Variable |
| C. | @Property |
| D. | @Autowired |
| Answer» E. | |
| 4. |
What does System.getProperty(“variable”) return? |
| A. | compilation error |
| B. | value stored in variable |
| C. | runtime error |
| D. | null |
| Answer» E. | |
| 5. |
Which system property stores installation directory of JRE? |
| A. | user.home |
| B. | java.class.path |
| C. | java.home |
| D. | user.dir |
| Answer» D. user.dir | |
| 6. |
Java system properties can be set at runtime. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 7. |
Which of the following is true about Java system properties? |
| A. | Java system properties are accessible by any process |
| B. | Java system properties are accessible by processes they are added to |
| C. | Java system properties are retrieved by System.getenv() |
| D. | Java system properties are set by System.setenv() |
| Answer» C. Java system properties are retrieved by System.getenv() | |
| 8. |
Which object Java application uses to create a new process? |
| A. | Process |
| B. | Builder |
| C. | ProcessBuilder |
| D. | CreateBuilder |
| Answer» D. CreateBuilder | |
| 9. |
What is true about the setProperties method? |
| A. | setProperties method changes the set of Java Properties which are persistent |
| B. | Changing the system properties within an application will affect future invocations |
| C. | setProperties method changes the set of Java Properties which are not persistent |
| D. | setProperties writes the values directly into the file which stores all the properties |
| Answer» D. setProperties writes the values directly into the file which stores all the properties | |
| 10. |
What does System.getProperty(“variable”) return?$ |
| A. | compilation error |
| B. | value stored in variable |
| C. | runtime error |
| D. | null |
| Answer» E. | |