Precise of 1Z0-804 free question materials and resource for Oracle certification for IT professionals, Real Success Guaranteed with Updated 1Z0-804 pdf dumps vce Materials. 100% PASS Java SE 7 Programmer II Exam exam Today!
2021 May 1Z0-804 Study Guide Questions:
Q21. Give: Which is correct?
A. Employee takes advantage of composition.
B. Employee "has-an" Email.
C. Employee "is-a" LetterPrinter.
D. Employee has low cohesion.
The relationship between Employee and e-mail is poorly implemented here.
There is low cohesion.
Low cohesion is associated with undesirable traits such as being difficult to maintain,
difficult to test, difficult toreuse, and even difficult to understand.
Cohesion is decreased if:
The functionalities embedded in a class, accessed through its methods, have little in
common. Methods carryout many varied activities, often using coarsely-grained or
unrelated sets of data. Disadvantages of lowcohesion (or"weak cohesion") are:
Increased difficulty in understanding modules.
Increased difficulty in maintaining a system, because logical changes in the domain affect
multiple modules,and because changes in one module require changes in related modules.
Increased difficulty in reusing amodule because most applications won't need the random
set of operations provided by a module.Reference:Cohesion (computer science)
Q22. Given these facts about Java types in an application:
Type x is a template for other types in the application.
Type x implements dostuff ().
Type x declares, but does NOT implement doit().
Type y declares doOther() .
Which three are true?
A. Type y must be an interface.
B. Type x must be an abstract class.
C. Type y must be an abstract class.
D. Type x could implement or extend from Type y.
E. Type x could be an abstract class or an interface.
F. Type y could be an abstract class or an interface.
Unlike interfaces, abstract classes can contain fields that are not static and final, and they can containimplemented methods. Such abstract classes are similar to interfaces, except that they provide a partialimplementation, leaving it to subclasses to complete the implementation. If an abstract class contains onlyabstract method declarations, it should be declared as an interface instead.
Note: An interface in the Java programming language is an abstract type that is used to specify an interface (in thegeneric sense of the term) that classes must implement. Interfaces are declaredusing the interface keyword,and may only contain method signature and constant declarations (variable declarations that are declared tobe both static and final). An interface maynever contain method definitions.
Note 2: an abstract class is a class that is declared abstract--it may or may not include abstract methods.Abstract classes cannot be instantiated, but they can be subclassed. An abstract method is a method that isdeclared without an implementation (without braces, and followed by a semicolon)
Q23. When using the default file system provider with a JVM running on a DOS-based file system, which statementis true?
A. DOS file attributes can be read as a set in a single method call.
B. DOS file attributes can be changed as a set in a single method call.
C. DOS file attributes can be modified for symbolic links and regular files.
D. DOS file attributes can be modified in the same method that creates the file.
File attributes associated with a file in a file system that supports legacy "DOS" attributes.
Path file = ...
DosFileAttributes attrs = Files.readAttributes(file, DosFileAttributes.class);
The methodreadAttributes() reads a file's attributes as a bulk operation.
Most up-to-date exam 1z0-804 vce:
Q24. Which two are true about Singletons?
A. A Singleton must implement serializable.
B. A Singleton has only the default constructor.
C. A Singleton implements a factory method.
D. A Singleton improves a class's cohesion.
E. Singletons can be designed to be thread-safe.
What is the result?
C. It may print"unknown"or"Daniel"depending on the JVM implementation.
D. Compilation fails.
E. An exception is thrown at runtime.
The compilation fails at line start(); Erstellen eines statischen Verweises auf die nicht statische Methode start() vom Typ Runner nicht m.glich.Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - non-static method start()cannot be referenced from a static context
Q26. The two methods of code reuse that aggregate the features located in multiple classes are ____________ ?
B. Copy and Paste
E. Virtual Method Invocation
A: Inheritance is a way of reusing code and building bigger more functional objects from a
The original little object, the parent, is called the super-class. The more functional object
that inherits from it iscalled the sub-class .
C: When your goal is code reuse, composition provides an approach that yields easier-to-change code.
Guaranteed ocp 1z0-804:
Q27. Which two actions can be used in registering a JDBC 3.0 driver?
A. Add the driver class to the META-INF/services folder of the JAR file.
B. Set the driver class name by using the jdbc.drivers system property.
C. Include the JDBC driver class in a jdbcproperties file.
D. Use the java.lang.class.forName method to load the driver class.
E. Use the DriverManager.getDriver method to load the driver class.
A: if your JDBC Driver is NOT JDBC 4-compliant then we can update the driver using "jar"-utility by adding the "META-INF /services/java.sql.Driver" inside it. as following: D:Dynamic loading of Java classes at runtime provides tremendous flexibility in the development of enterprisesystems. It provides for the basis of "application servers", and allows even simpler, lighter-weight systems toaccomplish some of the same ends. Within Java, dynamic-loading is typically achieved by calling the forNamemethod on the class java.lang.ClassAn example provided by the standard Java SE API is the ServiceLoader. Amongothers, the JDBC 4.0compatible drivers implement this. This way just dropping the JDBC driver JAR file folder will automatically loadthe driver class during Java application's startup/initialization without the need for any manual Class.forName("com.example.Driver") line in your code.
Q28. Given the code fragment:
What is the result, if the file salesreport.dat does not exist?
A. Compilation fails only at line 6
B. Compilation fails only at line 13
C. Compilation fails at line 6 and 13
D. Class java.io.IOException
E. Class java.io.FileNotFoundException
Compilation fails Line 13 : The resource br of a try-with-resources statement cannot be assignedresources are final in try-with-resources statements
Q29. An application is waiting for notification of changes to a tmp directory using the following code statements:
Path dir = Paths.get("tmp")
WatchKey key = dir.register (watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY) ;
In the tmp directory, the user renames the file testA to testB,
Which statement is true?
A. The events received and the order of events are consistent across all platforms.
B. The events received and the order of events are consistent across all Microsoft Windows versions.
C. The events received and the order of events are consistent across all UNIX platforms.
D. The events received and the order of events are platform dependent.
Most file system implementations have native support for file change notification. The
WatchService API takesadvantage of this support where available.
However, when a file system does not support this mechanism, the WatchService will poll
the file system,waiting for events.
WatchKey : When a Watchable entity is registered with a WatchService a key which is a
WatchKey isgenerated. Initially the key is in ready state waiting to be notified of any events
on the Watchable entity. Oncean event occurs the key goes into signaled state and allows
to access the events using its pollEvents method.
After processing the poll events the key has to be reset by invoking its reset method.
Reference: The Java Tutorials,Watching a Directory for Changes
Q30. Given the fragment:
Which two valid alternatives to line 3 would decouple this application from a specific implementation ofCustomerDAO?
A. CustomerDAO custDao = CustomerDAO();
B. CustomerDAO custDao = (CustomerDAO) new Object ();
C. CustomerDAO custDao = CustomerDAO.getInstance();
D. CustomerDAO custDao = (CustomerDAO) new CustomerDAOmemoryImp1();
E. CustomerDAO custDao = customerDAOFactory.getInstance();
Note: In software development, the term"decoupling"is used to identify the separation of software blocks thatshouldn't depend on each other. Some building blocks are generic and shouldn't know details of others. Special design techniques allow software designers to have as few dependencies as possible. This typicallyreduces the risk of malfunction in one part of a system when the other part changed. It also forces thedeveloper to focus on one thing at a time. Decoupling lowers or minimizes Coupling.