Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-804
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-804.html
Java SE 7 Programmer II
Question No: 1
Given:
Which three values will appear in the output?
-
5
-
7
-
a1
-
a2
-
b1
-
b2
Answer: A,D,E Explanation:
Staticmethod of base class is invoked gt;gt; A myA = new B();
System.out.print(myA.doA() myA.doA2() myA.a); class B String doA() { return quot;b1 quot;; }
class A protected static String doA2 () { return quot;a2 quot;; } class B int a = 7;
Question No: 2
Given:
What is the result?
-
false false
-
true false
-
true true
-
Compilation fails
-
An exception is thrown at runtime
Answer: A Explanation:
(this == obj) is the object implementation of equals() and therefore FALSE, if the reference points to variousobjectsand then the super.equals() is invoked, the object method equals() what still result in FALSEbetter override of equals() is to compare the attributes like:
public boolean equals (Object obj) { if (obj != null){
Product p = (Product)obj; return this.id == p.id;
}
return false;
}
Question No: 3
Given:
What is the result?
-
tolting cantering tolting
-
cantering cantering cantering
-
compilation fails
-
an exception is thrown at runtime
Answer: C Explanation:
Compiler says: Cannot reduce the visibility of the inherited method from Rideable. m眉ssen PUBLIC sein
public String ride() { return quot;cantering quot;; } public String ride() { return quot;tolting quot;; }
if this is given then the result would be: A : tolting cantering tolting
Question No: 4
Which four are syntactically correct?
-
package abc; package def; import Java.util . * ; public class Test { }
-
package abc; import Java.util.*;
import Java.util.regex.* ; public class Test { }
-
package abc; public class Test {} import Java.util.* ;
-
import Java.util.*; package abc;
public class Test {}
-
package abc; import java.util. *; public class Test{}
-
public class Test{} package abc;
import java.util.*{}
-
import java.util.*; public class Test{}
-
package abc; public class test {}
Answer: B,E,G,H
Question No: 5
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?
-
Type y must be an interface.
-
Type x must be an abstract class.
-
Type y must be an abstract class.
-
Type x could implement or extend from Type y.
-
Type x could be an abstract class or an interface.
-
Type y could be an abstract class or an interface.
Answer: B,D,F Explanation:
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)
Question No: 6
Given:
What two changes, made independently, will enable the code to compile?
-
Change the signature of Account to: public class Account.
-
Change the signature of CheckingAccount to: public abstract CheckingAccount
-
Implement private methods for deposit and withdraw in CheckingAccount.
-
Implement public methods for deposit and withdraw in CheckingAccount.
-
Change Signature of checkingAccount to: CheckingAccount implements Account.
-
Make Account an interface.
Answer: B,D Explanation: Compiler say:
-
-
Der Typ CheckingAccount muss die 眉bernommene abstrakte Methode Account.deposit(double) implementieren
-
Der Typ CheckingAccount muss die 眉bernommene abstrakte Methode Account.withdraw(double) implementieren
ODER
Typ CheckingAccount als abstract definieren
Question No: 7
Given:
Which fragment, inserted in the Books interface, enables the code to compile?
-
public abstract String type; public abstract String getType();
-
public static String type; public abstract String getType();
-
public String type = quot;Fictionquot;; public static String getType();
-
public String type = quot;Fictionquot;; public abstract String getType();
Answer: D
Question No: 8
Given:
What is the result?
-
Event Quiz
-
Event Event
-
Quiz Quiz
-
Quiz Event
-
Compilation fails
Answer: E
Question No: 9
Which two forms of abstraction can a programmer use in Java?
-
enums
-
interfaces
-
primitives
-
abstract classes
-
concrete classes
-
primitive wrappers
Answer: B,D Explanation:
When To Use Interfaces
An interface allows somebody to start from scratch to implement your interface or implement your interface insome other code whose original or primary purpose was quite different from your interface. To them, yourinterface is only incidental, something that have to add on to thetheir code to be able to use your package. Thedisadvantage is every method in the interface must be public. You might not want to expose everything.
*When To Use Abstract classes
An abstract class, in contrast, provides more structure. It usually defines some default implementations andprovides some tools useful for a full implementation. The catch is, code using it must use your class as thebase. That may be highly inconvenient if the other programmers wanting to use your package have alreadydeveloped their own class hierarchy independently. In Java, a class can inherit from only one base class.*When to Use Both
You can offer the best of both worlds, an interface and an abstract class. Implementors can ignore yourabstract class if they choose. The only drawback of doing that is calling methods via their interface name isslightly slower than calling them via their abstract class name.
Reference:http://mindprod.com/jgloss/interfacevsabstract.html
Question No: 10
Given:
What is the result?
-
Up Down
-
Up Up
-
Up null
-
Compilation fails
-
An exception is thrown at runtime
Answer: D Explanation:
—
Exception in thread quot;mainquot; java.lang.ExceptionInInitializerError at garden.Garden.main Caused by: java.lang.RuntimeException: Uncompilable source code – garden.Plant is not abstract and doesnot override abstract method growthDirection() in garden.Plant
100% Ensurepass Free Download!
–Download Free Demo:1z0-804 Demo PDF
100% Ensurepass Free Guaranteed!
–1z0-804 Dumps
EnsurePass | ExamCollection | Testking | |
---|---|---|---|
Lowest Price Guarantee | Yes | No | No |
Up-to-Dated | Yes | No | No |
Real Questions | Yes | No | No |
Explanation | Yes | No | No |
PDF VCE | Yes | No | No |
Free VCE Simulator | Yes | No | No |
Instant Download | Yes | No | No |
100-105 Dumps VCE PDF
200-105 Dumps VCE PDF
300-101 Dumps VCE PDF
300-115 Dumps VCE PDF
300-135 Dumps VCE PDF
300-320 Dumps VCE PDF
400-101 Dumps VCE PDF
640-911 Dumps VCE PDF
640-916 Dumps VCE PDF
70-410 Dumps VCE PDF
70-411 Dumps VCE PDF
70-412 Dumps VCE PDF
70-413 Dumps VCE PDF
70-414 Dumps VCE PDF
70-417 Dumps VCE PDF
70-461 Dumps VCE PDF
70-462 Dumps VCE PDF
70-463 Dumps VCE PDF
70-464 Dumps VCE PDF
70-465 Dumps VCE PDF
70-480 Dumps VCE PDF
70-483 Dumps VCE PDF
70-486 Dumps VCE PDF
70-487 Dumps VCE PDF
220-901 Dumps VCE PDF
220-902 Dumps VCE PDF
N10-006 Dumps VCE PDF
SY0-401 Dumps VCE PDF