6
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:   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".

Subject: Oracle Certification
Job Role: Analyst
Q:

Difference between Union and Union all?

Answer

The difference between Union and Union all is that Union all will not eliminate duplicate rows, instead it just pulls all rows from all tables fitting your query specifics and combines them into a table. A UNION statement effectively does a SELECT DISTINCT on the results set.

Report Error

View answer Workspace Report Error Discuss

1 1444
Q:

A subquery in an sql select statement.

Answer

A Subquery or Inner query or a Nested query is a query within another SQL query and embedded within the WHERE clause.


Subqueries are most frequently used with the SELECT statement. The basic syntax is as follows::


SELECT column_name [, column_name ]
FROM table1 [, table2 ]
WHERE column_name OPERATOR
(SELECT column_name [, column_name ]
FROM table1 [, table2 ]
[WHERE])



A subquery is used to return data that will be used in the main query as a condition to further restrict the data to be retrieved.


Subqueries can be used with the SELECT, INSERT, UPDATE, and DELETE statements along with the operators like =, <, >, >=, <=, IN, BETWEEN, etc.


 


There are a few rules that subqueries must follow −


 


1. Subqueries must be enclosed within parentheses.


2. A subquery can have only one column in the SELECT clause, unless multiple columns are in the main query for the subquery to compare its selected columns.


3. An ORDER BY command cannot be used in a subquery, although the main query can use an ORDER BY. The GROUP BY command can be used to perform the same function as the ORDER BY in a subquery.


4. Subqueries that return more than one row can only be used with multiple value operators such as the IN operator.


5. The SELECT list cannot include any references to values that evaluate to a BLOB, ARRAY, CLOB, or NCLOB.


6. A subquery cannot be immediately enclosed in a set function.


7. The BETWEEN operator cannot be used with a subquery. However, the BETWEEN operator can be used within the subquery.

Report Error

View answer Workspace Report Error Discuss

0 1682
Q:

The SQL keyword BETWEEN is used:

A) for ranges B) as a wildcard
C) to limit the columns displayed D) All the above
 
Answer & Explanation Answer: A) for ranges

Explanation:

In SQL, BETWEEN Keyword is used for ranges like Number Ranges, Date Ranges, etc...

Report Error

View Answer Report Error Discuss

0 2452
Q:

Candidate Key in DBMS?

Answer

A candidate key is a column, or set of columns, in a table that can uniquely identify any database record without referring to any other data. Each table may have one or more candidate keys, but one candidate key is unique, and it is called the primary key.

Report Error

View answer Workspace Report Error Discuss

1 1559
Q:

Foreign key in DBMS is

Answer

Foreign keys are the columns of a table that points to the primary key of another table. They act as a cross-reference between tables.


 


In detail : A Foreign key is a field (or collection of fields) in one table that uniquely identifies a row of another table or the same table. In simpler words, the foreign key is defined in a second table, but it refers to the primary key or a unique key in the first table.

Report Error

View answer Workspace Report Error Discuss

1 1398
Q:

A Transparent DBMS

A) Keep its logical structure hidden from users B) Can access control
C) Keeps its physical structure hidden from users D) Can not hide sensitive information from users
 
Answer & Explanation Answer: C) Keeps its physical structure hidden from users

Explanation:

DBMS :: Database Managemet System.

A DBMS which keeps its physical structure hidden from the user is known as a transparent DBMS.

Report Error

View Answer Report Error Discuss

2 2670
Q:

What is Primary Key in DBMS?

Answer

A primary key is a special relational database table column or combination of columns designated to uniquely identify all table records. That is, A primary key is a column or set of columns in a table that uniquely identifies tuples (rows) in that table.


A primary key, also called a Primary Keyword.



Main Features Primary key are ::


It must contain a unique value for each row of data.


It cannot contain null values.

Report Error

View answer Workspace Report Error Discuss

10 2000
Q:

what will be the output of the following code?

class Value
{
    public int i = 15;
}
public class Test
{
    public static void main(String argv[])
    {
        Test t = new Test();
        t.first();
    }
    public void first()
    {
        int i = 5;
        Value v = new Value();
        v.i = 25;
        second(v, i);
        System.out.println(v.i);
    }
    public void second(Value v, int i)
    {
        i = 0;
        v.i = 20;
        Value val = new Value();
        v =  val;
        System.out.println(v.i + " " + i);
    }
}

A) 15 0 2 B) 15 0 0
C) 15 20 0 D) 15 0 20
 
Answer & Explanation Answer: D) 15 0 20

Explanation:
Report Error

View Answer Report Error Discuss

3 4756