7
Q:

In the following pieces of code, B and D will compile without any error. True or false ?

A: StringBuffer sb1 = "abcd";

B: Boolean b = new Boolean("abcd");

C: byte b = 255;

D: int x = 0x1234;

E: float fl = 1.2;

 

A) TRUE B) FALSE

Answer:   A) TRUE



Explanation:

The code segments B and D will compile without any error. A is not a valid way to construct a StringBuffer, you need to create a StringBuffer object using "new". B is a valid construction of a Boolean (any string other than "true" or "false" to the Boolean constructor will result in a Boolean with a value of "false"). C will fail to compile because the valid range for a byte is -128 to +127 (i.e., 8 bits, signed). D is correct, 0x1234 is the hexadecimal representation in java. E fails to compile because the compiler interprets 1.2 as a double being assigned to a float (down-casting), which is not valid. You either need an explicit cast, as in "(float)1.2" or "1.2f", to indicate a float.

Q:

What is the output after compile and run the following code ?

int Output = 10;
boolean b = false;
if((b == true) && ((Output += 10) == 20))
{
System.out.println("We are equal " + Output);
}
else
{
System.out.println("Not equal! " + Output);
}

A) Compilation and output of "We are equal 10" B) Compilation and output of "Not equal! 10"
C) Compilation error, attempting to perform binary comparison on logical data type D) Compilation and output of "Not equal! 20"
 
Answer & Explanation Answer: B) Compilation and output of "Not equal! 10"

Explanation:

The output will be "Not equal! 10". Please note that && is logical AND operator. If first operand before (&&) is false then the other operand will not be evaluated. This illustrates that the Output +=10 calculation was never performed because processing stopped after the first operand was evaluated to be false. If you change the value of b1 to true, processing occurs as you would expect and the output would be "We are equal 20".

Report Error

View Answer Report Error Discuss

Filed Under: Oracle Certification
Job Role: Analyst

6 5423
Q:

What is the default return value of a function?

A) int B) char
C) string D) None of the above
 
Answer & Explanation Answer: A) int

Explanation:

The default return value from a function is int. In other words, unless explicitly specified the default return value by compiler would be integer value from function.

Report Error

View Answer Report Error Discuss

3 3693
Q:

What is the difference between oracle,sql and sql server?

Answer

  • Oracle is based on RDBMS.

  • SQL is Structured Query Language.

  • SQL Server is another tool for RDBMS provided by MicroSoft


 

Report Error

View answer Workspace Report Error Discuss

2 2890
Q:

Which among the following keys are used to identify each row of the table uniquely?

A) Primary key B) Unique key
C) Partial key D) None of the above
 
Answer & Explanation Answer: A) Primary key

Explanation:

Primary key helps us to identify a row uniquely in a relation

Report Error

View Answer Report Error Discuss

2 3648
Q:

A column defined as UNIQUE can contain Nulls while a column defined as PRIMARY KEY can't contain Nulls

A) TRUE B) FALSE
Answer & Explanation Answer: A) TRUE

Explanation:

Because a table can have only one primary key

Report Error

View Answer Workspace Report Error Discuss

1 4152
Q:

What is an Oracle index?

Answer

An index is an optional structure associated with a table to have direct access to rows, which can be created to increase the performance of data retrieval. Index can be created on one or more columns of a table.

Report Error

View answer Workspace Report Error Discuss

3 2763
Q:

What command would you use to create a backup control file?

Answer

Alter database backup control file to trace

Report Error

View answer Workspace Report Error Discuss

3 2494
Q:

What is the maximum number of triggers, can apply to a single table?

A) 8 B) 10
C) 12 D) 14
 
Answer & Explanation Answer: C) 12

Explanation:

Maximim number of triggers that can be applied to a single table is 12

Report Error

View Answer Report Error Discuss

7 5584