<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Java Programming World</title>
	<atom:link href="http://www.javaprogrammingworld.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javaprogrammingworld.com</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Fri, 18 Sep 2009 19:54:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New Language Running on the JVM</title>
		<link>http://www.javaprogrammingworld.com/new-language-running-on-the-jvm/</link>
		<comments>http://www.javaprogrammingworld.com/new-language-running-on-the-jvm/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 16:36:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Java Programming Tutorials]]></category>

		<guid isPermaLink="false">http://www.javaprogrammingworld.com/?p=110</guid>
		<description><![CDATA[Google and several other companies have intorduced a new language experiment called Noop that runs on the JVM. It tried to include all the best practices in the programming world while discouraging the the worst ones. On their Google Code site the following reasons to use Noop over other languages.
Dependency Injection changed the way we [...]]]></description>
			<content:encoded><![CDATA[<p>Google and several other companies have intorduced a new language experiment called <a href="http://code.google.com/p/noop/">Noop</a> that runs on the JVM. It tried to include all the best practices in the programming world while discouraging the the worst ones. On their <a href="http://code.google.com/p/noop/">Google Code</a> site the following reasons to use Noop over other languages.</p>
<blockquote><p><a name="Why_Noop?">Dependency Injection changed the way we write software. Spring overtook EJB&#8217;s in thoughtful enterprises, and Guice and PicoContainer are an important part of many well-written applications today. </a></p>
<p><a name="Why_Noop?">Automated testing, especially Unit Testing, is also a crucial part of building reliable software that you can feel confident about supporting and changing over its lifetime. Any decent software shop should be writing some tests, the best ones are test-driven and have good code coverage. </a></p>
<p><a name="Why_Noop?">Noop is a new language that will run on the Java Virtual Machine, and in source form will look similar to Java. The goal is to build dependency injection and testability into the language from the beginning, rather than rely on third-party libraries as other languages do. </a></p>
<p><a name="Why_Noop?">Immutability and minimal variable scope are encouraged by making final/const behavior the default and providing easy access to a functional style. Testability is encouraged by providing Dependency Injection at the language level and a compact constructor injection syntax. </a></p></blockquote>
<p>Their <a href="http://code.google.com/p/noop/">Google Code</a> site also has these suggestions for the use of their Noop source files:</p>
<blockquote><p>1. <a name="Why_Noop?">Java translator: produces Java source. Allows you to use Noop without converting your codebase, but not all runtime features of the language are provided. </a></p>
<p>2. <a name="Why_Noop?">Interpreter: reads and evaluates the Noop code through an interpreter. Slower, but will have a command-line interface </a></p>
<p>3. <a name="Why_Noop?">Compiled: to Java bytecode. </a></p></blockquote>
<p>Noop is part of the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a> code Licencse. Their <a href="http://code.google.com/p/noop/wiki/ForDevelopers">getting started</a> page is very informatiove and tells you how to get Noop installed and configured easily. Noop has an extensive <a href="http://code.google.com/p/noop/wiki/Features">features list</a>. I can not see this replacing Java, but I do see it being the main development source for the android in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/new-language-running-on-the-jvm/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SDK update for Java FX</title>
		<link>http://www.javaprogrammingworld.com/sdk-update-for-java-fx/</link>
		<comments>http://www.javaprogrammingworld.com/sdk-update-for-java-fx/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 15:19:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.javaprogrammingworld.com/?p=106</guid>
		<description><![CDATA[As many of you know the new SDK update was release for Java FX. Their are many significant changes that have been made. Most are for the better. Below are some new classes that have been added for creating UI controls.

 Behavior
 Button
 ButtonBase
 CheckBox
 Control
 Hyperlink
 Keystroke
 Label
 Labeled
 ListView
 ProgressBar
 ProgressIndicator
 RadioButton
 ScrollBar
 [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you know the new SDK update was release for Java FX. Their are many significant changes that have been made. Most are for the better. Below are some new classes that have been added for creating UI controls.</p>
<ul>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Behavior.html"><code>Behavior</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Button.html"><code>Button</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.ButtonBase.html"><code>ButtonBase</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.CheckBox.html"><code>CheckBox</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Control.html"><code>Control</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Hyperlink.html"><code>Hyperlink</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Keystroke.html"><code>Keystroke</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Label.html"><code>Label</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Labeled.html"><code>Labeled</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.ListView.html"><code>ListView</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.ProgressBar.html"><code>ProgressBar</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.ProgressIndicator.html"><code>ProgressIndicator</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.RadioButton.html"><code>RadioButton</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.ScrollBar.html"><code>ScrollBar</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Skin.html"><code>Skin</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.Slider.html"><code>Slider</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.TextBox.html"><code>TextBox</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.TextInputControl.html"><code>TextInputControl</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.ToggleButton.html"><code>ToggleButton</code></a></li>
<li> <a href="http://java.sun.com/javafx/1.2/docs/api/javafx.scene.control/javafx.scene.control.ToggleGroup.html"><code>ToggleGroup</code></a></li>
</ul>
<p>To me these are a significant because this will make creating new UI controls a great deal easier then they have been in the past.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/sdk-update-for-java-fx/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JavaFX</title>
		<link>http://www.javaprogrammingworld.com/javafx/</link>
		<comments>http://www.javaprogrammingworld.com/javafx/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 16:58:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Java Programming Tutorials]]></category>

		<category><![CDATA[Videos]]></category>

		<guid isPermaLink="false">http://www.javaprogrammingworld.com/?p=100</guid>
		<description><![CDATA[Sun has released a new video that shows some of the new features of JavaFX. They are demonstrated by Jacob Lehrbaum, Senior Product Line Manager for JavaFX Marketing.
JavaFX is a platform for creating and delivering Rich Internet Applications (RIAs) &#8212; web applications that use rich media types such as video, audio, graphics, and rich text [...]]]></description>
			<content:encoded><![CDATA[<p>Sun has released a <a href="http://java.sun.com/developer/media/deepdivejavafx.jsp">new video</a> that shows some of the new features of JavaFX. They are demonstrated by Jacob Lehrbaum, Senior Product Line Manager for JavaFX Marketing.</p>
<blockquote><p>JavaFX is a platform for creating and delivering Rich Internet Applications (RIAs) &#8212; web applications that use rich media types such as video, audio, graphics, and rich text &#8212; that can run in a wide variety of devices, anywhere from handsets-to-laptops-to desktops. In many cases, you can compile and run the same JavaFX application code in a mobile environment, a desktop environment, or in a browser.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/javafx/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Oracle PL/SQL</title>
		<link>http://www.javaprogrammingworld.com/using-oracle-plsql/</link>
		<comments>http://www.javaprogrammingworld.com/using-oracle-plsql/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 19:51:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PL/SQL Tutorials]]></category>

		<guid isPermaLink="false">http://pimp.com/?p=98</guid>
		<description><![CDATA[Using Oracle PL/SQL


Basic    Structure of PL/SQL
Variables    and Types
Simple    PL/SQL Programs
Control    Flow in PL/SQL
Cursors
Procedures
Discovering    Errors
Printing    Variables

Basic Structure of PL/SQLPL/SQL  stands for Procedural Language/SQL. PL/SQL extends SQL by adding constructs  found in procedural languages, resulting in a [...]]]></description>
			<content:encoded><![CDATA[<h1>Using Oracle PL/SQL</h1>
<hr />
<ul>
<li>Basic    Structure of PL/SQL</li>
<li>Variables    and Types</li>
<li>Simple    PL/SQL Programs</li>
<li>Control    Flow in PL/SQL</li>
<li>Cursors</li>
<li>Procedures</li>
<li>Discovering    Errors</li>
<li>Printing    Variables</li>
</ul>
<hr />Basic Structure of PL/SQLPL/SQL  stands for Procedural Language/SQL. PL/SQL extends SQL by adding constructs  found in procedural languages, resulting in a structural language that is more  powerful than SQL. The basic unit in PL/SQL is a <em>block</em>. All PL/SQL  programs are made up of blocks, which can be nested within each other.  Typically, each block performs a logical action in he program. A block has the  following structure:</p>
<pre>    DECLARE

    /* Declarative section: variables, types, and local subprograms. */

    BEGIN

    /* Executable section: procedural and SQL statements go here. */

    /* This is the only section of the block that is required. */

    EXCEPTION

    /* Exception handling section: error handling statements go here. */

    END;</pre>
<p>Only the executable section is required. The other  sections are optional. The only SQL statements allowed in a PL/SQL program are  <tt>SELECT</tt>, <tt>INSERT</tt>, <tt>UPDATE</tt>, <tt>DELETE</tt> and several  other data manipulation statements plus some transaction control. However, the  <tt>SELECT</tt> statement has a special form in which a single tuple is placed  in variables; more on this later. Data definition statements like  <tt>CREATE</tt>, <tt>DROP</tt>, or <tt>ALTER</tt> are not allowed. The  executable section also contains constructs such as assignments, branches,  loops, procedure calls, and triggers,  which are all described below (except triggers).  PL/SQL is not case sensitive. C style comments (<tt>/* &#8230; */</tt>) may be used.</p>
<p>To execute a PL/SQL program, we must follow the program text itself by</p>
<ul>
<li>A line with a single dot (&#8221;<tt>.</tt>&#8220;), and then</li>
<li>A line with <tt>run;</tt></li>
</ul>
<p>As with Oracle SQL programs, we can  invoke a PL/SQL program either by typing it in <tt>sqlplus</tt> or by putting  the code in a file and invoking the file in the various ways we learned in Getting  Started With Oracle.</p>
<hr />Variables and Types Information is  transmitted between a PL/SQL program and the database through <em>variables</em>.  Every variable has a specific type associated with it. That type can be</p>
<ul>
<li>One of the types used by SQL for database columns</li>
<li>A generic type used in PL/SQL such as <tt>NUMBER</tt></li>
<li>Declared to be the same as the type of some database column</li>
</ul>
<p>The  most commonly used generic type is <tt>NUMBER</tt>. Variables of type  <tt>NUMBER</tt> can hold either an integer or a real number. The most commonly  used character string type is <tt>VARCHAR(</tt><em>n</em><tt>)</tt>, where  <em>n</em> is the maximum length of the string in bytes. This length is required,  and there is no default. For example, we might declare:</p>
<pre>DECLARE

    price  NUMBER;

    myBeer VARCHAR(20);</pre>
<p>Note that PL/SQL allows  <tt>BOOLEAN</tt> variables, even though Oracle does not support <tt>BOOLEAN</tt> as a type for database columns.</p>
<p>Types in PL/SQL can be tricky. In many cases, a PL/SQL variable will be used  to manipulate data stored in a existing relation. In this case, it is essential  that the variable have the same type as the relation column. If there is any  type mismatch, variable assignments and comparisons may not work the way you  expect. To be safe, instead of hard coding the type of a variable, you should  use the <tt>%TYPE</tt> operator. For example:</p>
<pre>DECLARE

    myBeer Beers.name%TYPE;</pre>
<p>gives PL/SQL variable  <tt>myBeer</tt> whatever type was declared for the <tt>name</tt> column in  relation <tt>Beers</tt>.</p>
<p>A variable may also have a type that is a record with several fields. The  simplest way to declare such a variable is to use <tt>%ROWTYPE</tt> on a  relation name. The result is a record type in which the fields have the same  names and types as the attributes of the relation. For instance:</p>
<pre>DECLARE

    beerTuple Beers%ROWTYPE;</pre>
<p>makes variable  <tt>beerTuple</tt> be a record with fields <tt>name</tt> and  <tt>manufacture</tt>, assuming that the relation has the schema <tt>Beers(name,  manufacture)</tt></p>
<p>.</p>
<p>The initial value of any variable, regardless of its type, is <tt>NULL</tt>.  We can assign values to variables, using the &#8220;<tt>:=</tt>&#8221; operator. The  assignment can occur either immediately after the type of the variable is  declared, or anywhere in the executable portion of the program. An example:</p>
<pre>DECLARE

    a NUMBER := 3;

BEGIN

    a := a + 1;

END;

.

run;</pre>
<p>This program has no effect when run, because there are no changes to  the database.</p>
<hr />Simple Programs in PL/SQLThe  simplest form of program has some declarations followed by an executable section  consisting of one or more of the SQL statements with which we are familiar. The  major nuance is that the form of the <tt>SELECT</tt> statement is different from  its SQL form. After the <tt>SELECT</tt> clause, we <em>must</em> have an  <tt>INTO</tt> clause listing variables, one for each attribute in the  <tt>SELECT</tt> clause, into which the components of the retrieved tuple must be  placed.</p>
<p>Notice we said &#8220;tuple&#8221; rather than &#8220;tuples&#8221;, since the <tt>SELECT</tt> statement in PL/SQL only works if the result of the query contains a single  tuple. The situation is essentially the same as that of the &#8220;single-row select&#8221;  discussed in Section 7.1.5 of the text, in connection with embedded SQL. If the  query returns more than one tuple, you need to use a <em>cursor</em>, as described  in the next section. Here is an example:</p>
<pre>CREATE TABLE T1(

    e INTEGER,

    f INTEGER

);

DELETE FROM T1;

INSERT INTO T1 VALUES(1, 3);

INSERT INTO T1 VALUES(2, 4);

/* Above is plain SQL; below is the PL/SQL program. */

DECLARE

    a NUMBER;

    b NUMBER;

BEGIN

    SELECT e,f INTO a,b FROM T1 WHERE e&gt;1;

    INSERT INTO T1 VALUES(b,a);

END;

.

run;</pre>
<p>Fortuitously, there is only one tuple of <tt>T1</tt> that has first  component greater than 1, namely (2,4). The <tt>INSERT</tt> statement thus  inserts (4,2) into <tt>T1</tt></p>
<p>.</p>
<hr />Control Flow in PL/SQLPL/SQL allows  you to branch and create loops in a fairly familiar way.</p>
<p>An <tt>IF</tt> statement looks like:</p>
<pre>IF &lt;condition&gt; THEN &lt;statement_list&gt; ELSE &lt;statement_list&gt; END IF;</pre>
<p>The  <tt>ELSE</tt> part is optional. If you want a multiway branch, use:</p>
<pre>IF &lt;condition_1&gt; THEN ...

ELSIF &lt;condition_2&gt; THEN ...

... ...

ELSIF &lt;condition_n&gt; THEN ...

ELSE ...

END IF;</pre>
<p>The following is an example, slightly modified from the previous  one, where now we only do the insertion if the second component is 1. If not, we  first add 10 to each component and then insert:</p>
<pre>DECLARE

    a NUMBER;

    b NUMBER;

BEGIN

    SELECT e,f INTO a,b FROM T1 WHERE e&gt;1;

    IF b=1 THEN

        INSERT INTO T1 VALUES(b,a);

    ELSE

        INSERT INTO T1 VALUES(b+10,a+10);

    END IF;

END;

.

run;</pre>
<p>Loops are created with the following:</p>
<pre>LOOP

    &lt;loop_body&gt; /* A list of statements. */

END LOOP;</pre>
<p>At least one of the statements in <tt>&lt;loop_body&gt;</tt> should be an <tt>EXIT</tt> statement of the form</p>
<pre>EXIT WHEN &lt;condition&gt;;</pre>
<p>The loop breaks if  <tt>&lt;condition&gt;</tt> is true. For example, here is a way to insert each of  the pairs (1, 1) through (100, 100) into <tt>T1</tt> of the above two examples:</p>
<pre>DECLARE

    i NUMBER := 1;

BEGIN

    LOOP

        INSERT INTO T1 VALUES(i,i);

        i := i+1;

        EXIT WHEN i&gt;100;

    END LOOP;

END;

.

run;</pre>
<p>Some other useful loop-forming statements are:</p>
<ul>
<li><tt>EXIT</tt> by itself is an unconditional loop break. Use it inside a    conditional if you like.</li>
<li>A <tt>WHILE</tt> loop can be formed with
<pre>    WHILE &lt;condition&gt; LOOP

        &lt;loop_body&gt;

    END LOOP;</pre>
</li>
<li>A simple <tt>FOR</tt> loop can be formed with:
<pre>    FOR &lt;var&gt; IN &lt;start&gt;..&lt;finish&gt; LOOP

        &lt;loop_body&gt;

    END LOOP;</pre>
<p>Here, <tt>&lt;var&gt;</tt> can be any    variable; it is local to the for-loop and need not be declared. Also,    <tt>&lt;start&gt;</tt> and <tt>&lt;finish&gt;</tt> are constants.</li>
</ul>
<hr />CursorsA <em>cursor</em> is a variable that runs through  the tuples of some relation. This relation can be a stored table, or it can be  the answer to some query. By fetching into the cursor each tuple of the  relation, we can write a program to read and process the value of each such  tuple. If the relation is stored, we can also update or delete the tuple at the  current cursor position.</p>
<p>The example below illustrates a cursor loop. It uses our example relation  <tt>T1(e,f)</tt> whose tuples are pairs of integers. The program will delete  every tuple whose first component is less than the second, and insert the  reverse tuple into <tt>T1</tt>.</p>
<pre> 1) DECLARE

        /* Output variables to hold the result of the query: */

 2)     a T1.e%TYPE;

 3)     b T1.f%TYPE;

        /* Cursor declaration: */

 4)     CURSOR T1Cursor IS

 5)         SELECT e, f

 6)         FROM T1

 7)         WHERE e &lt; f

 8)         FOR UPDATE;

 9) BEGIN

10)     OPEN T1Cursor;

11)     LOOP

            /* Retrieve each row of the result of the above query

               into PL/SQL variables: */

12)         FETCH T1Cursor INTO a, b;

            /* If there are no more rows to fetch, exit the loop: */

13)         EXIT WHEN T1Cursor%NOTFOUND;

            /* Delete the current tuple: */

14)         DELETE FROM T1 WHERE CURRENT OF T1Cursor;

            /* Insert the reverse tuple: */

15)         INSERT INTO T1 VALUES(b, a);

16)     END LOOP;

        /* Free cursor used by the query. */

17)     CLOSE T1Cursor;

18) END;

19) .

20) run;</pre>
<p>Here are explanations for the various lines of this program:</p>
<ul>
<li>Line (1) introduces the declaration section.</li>
<li>Lines (2) and (3) declare variables <tt>a</tt> and <tt>b</tt> to have    types equal to the types of attributes <tt>e</tt> and <tt>f</tt> of the    relation <tt>T1</tt>. Although we know these types are <tt>INTEGER</tt>, we    wisely make sure that whatever types they may have are copied to the PL/SQL    variables (compare with the previous example, where we were less careful and    declared the corresponding variables to be of type <tt>NUMBER</tt>).</li>
<li>Lines (4) through (8) define the cursor <tt>T1Cursor</tt>. It ranges over    a relation defined by the <tt>SELECT</tt>-<tt>FROM</tt>-<tt>WHERE</tt> query.    That query selects those tuples of <tt>T1</tt> whose first component is less    than the second component. Line (8) declares the cursor <tt>FOR UPDATE</tt> since we will modify <tt>T1</tt> using this cursor later on Line (14). In    general, <tt>FOR UPDATE</tt> is unnecessary if the cursor will not be used for    modification.</li>
<li>Line (9) begins the executable section of the program.</li>
<li>Line (10) opens the cursor, an essential step.</li>
<li>Lines (11) through (16) are a PL/SQL loop. Notice that such a loop is    bracketed by <tt>LOOP</tt> and <tt>END LOOP</tt>. Within the loop we find:
<ul>
<li>On Line (12), a fetch through the cursor into the local variables. In      general, the <tt>FETCH</tt> statement must provide variables for each      component of the tuple retrieved. Since the query of Lines (5) through (7)      produces pairs, we have correctly provided two variables, and we know they      are of the correct type.</li>
<li>On Line (13), a test for the loop-breaking condition. Its meaning should      be clear: <tt>%NOTFOUND</tt> after the name of a cursor is true exactly when      a fetch through that cursor has failed to find any more tuples.</li>
<li>On Line (14), a SQL <tt>DELETE</tt> statement that deletes the current      tuple using the special <tt>WHERE</tt> condition <tt>CURRENT OF      T1Cursor</tt>.</li>
<li>On Line (15), a SQL <tt>INSERT</tt> statement that inserts the reverse      tuple into <tt>T1</tt>.</li>
</ul>
</li>
<li>Line (17) closes the cursor.</li>
<li>Line (18) ends the PL/SQL program.</li>
<li>Lines (19) and (20) cause the program to execute.</li>
</ul>
<h3></h3>
<hr />ProceduresPL/SQL procedures behave very much like  procedures in other programming language. Here is an example of a PL/SQL  procedure <tt>addtuple1</tt> that, given an integer <tt>i</tt>, inserts the  tuple <tt>(i, &#8216;xxx&#8217;)</tt> into the following example relation:</p>
<pre>CREATE TABLE T2 (

    a INTEGER,

    b CHAR(10)

);

CREATE PROCEDURE addtuple1(i IN NUMBER) AS

BEGIN

    INSERT INTO T2 VALUES(i, 'xxx');

END addtuple1;

.

run;</pre>
<p>A procedure is introduced by the keywords <tt>CREATE PROCEDURE</tt> followed by the procedure name and its parameters. An option is to follow  <tt>CREATE</tt> by <tt>OR REPLACE</tt>. The advantage of doing so is that should  you have already made the definition, you will not get an error. On the other  hand, should the previous definition be a different procedure of the same name,  you will not be warned, and the old procedure will be lost.</p>
<p>There can be any number of parameters, each followed by a <em>mode</em> and a  type. The possible modes are <tt>IN</tt> (read-only), <tt>OUT</tt> (write-only),  and <tt>INOUT</tt> (read and write). <strong>Note:</strong> Unlike the type specifier in a  PL/SQL variable declaration, the type specifier in a parameter declaration must  be unconstrained. For example, <tt>CHAR(10)</tt> and <tt>VARCHAR(20)</tt> are  illegal; <tt>CHAR</tt> or <tt>VARCHAR</tt> should be used instead. The actual  length of a parameter depends on the corresponding argument that is passed in  when the procedure is invoked.</p>
<p>Following the arguments is the keyword <tt>AS</tt> (<tt>IS</tt> is a  synonym). Then comes the body, which is essentially a PL/SQL block. We have  repeated the name of the procedure after the <tt>END</tt>, but this is optional.  However, the <tt>DECLARE</tt> section should <em>not</em> start with the keyword  <tt>DECLARE</tt>. Rather, following <tt>AS</tt> we have:</p>
<pre>... AS

&lt;local_var_declarations&gt;

BEGIN

    &lt;procedure_body&gt;

END;

.

run;</pre>
<p>The <tt>run</tt> at the end runs the statement that <em>creates</em> the  procedure; it does not execute the procedure. To execute the procedure, use  another PL/SQL statement, in which the procedure is invoked as an executable  statement. For example:</p>
<pre>BEGIN addtuple1(99); END;

.

run;</pre>
<p>The following procedure also inserts a tuple into <tt>T2</tt>, but it  takes both components as arguments:</p>
<pre>CREATE PROCEDURE addtuple2(

    x T2.a%TYPE,

    y T2.b%TYPE)

AS

BEGIN

    INSERT INTO T2(a, b)

    VALUES(x, y);

END addtuple2;

.

run;</pre>
<p>Now, to add a tuple <tt>(10, &#8216;abc&#8217;)</tt> to <tt>T2</tt></p>
<p>:</p>
<pre>BEGIN

    addtuple2(10, 'abc');

END;

.

run;</pre>
<p>The following illustrates the use of an <tt>OUT</tt> parameter:</p>
<pre>CREATE TABLE T3 (

    a INTEGER,

    b INTEGER

);

CREATE PROCEDURE addtuple3(a NUMBER, b OUT NUMBER)

AS

BEGIN

    b := 4;

    INSERT INTO T3 VALUES(a, b);

END;

.

run;

DECLARE

    v NUMBER;

BEGIN

    addtuple3(10, v);

END;

.

run;</pre>
<p>Note that assigning values to parameters declared as <tt>OUT</tt> or  <tt>INOUT</tt> causes the corresponding input arguments to be written. Because  of this, the input argument for an <tt>OUT</tt> or <tt>INOUT</tt> parameter  should be something with an &#8220;lvalue&#8221;, such as a variable like <tt>v</tt> in the  example above. A constant or a literal argument should not be passed in for an  <tt>OUT</tt>/<tt>INOUT</tt> parameter.</p>
<p>We can also write functions instead of procedures. In a function declaration,  we follow the parameter list by <tt>RETURN</tt> and the type of the return  value:</p>
<pre>CREATE FUNCTION &lt;func_name&gt;(&lt;param_list&gt;) RETURN &lt;return_type&gt; AS ...</pre>
<p>In  the body of the function definition, &#8220;<tt>RETURN &lt;expression&gt;</tt>;&#8221; exits  from the function and returns the value of <tt>&lt;expression&gt;</tt></p>
<p>.</p>
<p>To find out what procedures and functions you have created, use the following  SQL query:</p>
<pre>select object_type, object_name

from user_objects

where object_type = 'PROCEDURE'

   or object_type = 'FUNCTION';</pre>
<p>To drop a stored  procedure/function:</p>
<pre>drop procedure &lt;procedure_name&gt;;

drop function &lt;function_name&gt;;</pre>
<hr />Discovering ErrorsPL/SQL does not always tell you about  compilation errors. Instead, it gives you a cryptic message such as &#8220;procedure  created with compilation errors&#8221;. If you don&#8217;t see what is wrong immediately,  try issuing the command</p>
<pre>show errors procedure &lt;procedure_name&gt;;</pre>
<p>Alternatively, you can  type, <tt>SHO ERR</tt> (short for <tt>SHOW ERRORS</tt>) to see the most recent  compilation error.</p>
<p>Note that the location of the error given as part of the error message is not  always accurate!</p>
<hr />Printing VariablesSometimes we might want to print the  value of a PL/SQL local variable. A &#8220;quick-and-dirty&#8221; way is to store it as  the sole tuple of some relation and after the PL/SQL statement print the  relation with a <tt>SELECT</tt> statement. A more couth way is to define a  <em>bind variable</em>, which is the only kind that may be printed with a  <tt>print</tt> command. Bind variables are the kind that must be prefixed with a  colon in PL/SQL statements, such as <tt>:new</tt> discussed in the section on triggers.</p>
<p>The steps are as follows:</p>
<ol>
<li>We declare a bind variable as follows:
<pre>     VARIABLE &lt;name&gt; &lt;type&gt;</pre>
<p>where    the type can be only one of three things: <tt>NUMBER</tt>, <tt>CHAR</tt>, or    <tt>CHAR(<em>n</em>)</tt>.</li>
<li>We may then assign to the variable in a following PL/SQL statement, but we    must prefix it with a colon.</li>
<li>Finally, we can execute a statement
<pre>     PRINT :&lt;name&gt;;</pre>
<p>outside the PL/SQL    statement</li>
</ol>
<p>Here is a trivial example, which prints the value 1.</p>
<pre>     VARIABLE x NUMBER

     BEGIN

          <img src='http://www.javaprogrammingworld.com/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> := 1;

     END;

     .

     run;

     PRINT :x;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/using-oracle-plsql/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PL/SQL Everything by Somdutt Ganguly</title>
		<link>http://www.javaprogrammingworld.com/plsql-everything-by-somdutt-ganguly/</link>
		<comments>http://www.javaprogrammingworld.com/plsql-everything-by-somdutt-ganguly/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 19:49:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PL/SQL Tutorials]]></category>

		<guid isPermaLink="false">http://pimp.com/?p=96</guid>
		<description><![CDATA[
PL/SQL TUTORIAL

 WHAT IS PL/SQL
pl/sql is the procedural implementation of sql i.e. u can pass sql statements in procedural format using pl/sql. Normal sql does not have any procedural capabilities moreover u can only pass one statement at a time to Oracle Engine. Hence, pl/sql have come up to avoid this limitation. Hence, pl/sql is [...]]]></description>
			<content:encoded><![CDATA[<hr />
<h1><span style="font-family: Verdana; font-size: small;">PL/SQL TUTORIAL</span></h1>
<hr />
<h3><span style="font-family: Verdana; font-size: small;"> WHAT IS PL/SQL</span></h3>
<p><span style="font-family: Verdana; font-size: small;">pl/sql is the procedural implementation of sql i.e. u can pass sql statements in procedural format using pl/sql. Normal sql does not have any procedural capabilities moreover u can only pass one statement at a time to Oracle Engine. Hence, pl/sql have come up to avoid this limitation. Hence, pl/sql is the structured programming language for oracle. It&#8217;s structure is very much similar to any other procedural language such as C or C++</span></p>
<p><span style="font-family: Verdana; font-size: small;"> I won&#8217;t waste your time in typing out the advantages of pl/sql &#8230; u can easily find out in a book.</span></p>
<h4><span style="font-family: Verdana; font-size: small;"> PL/SQL BLOCK</span></h4>
<p><span style="font-family: Verdana; font-size: small;"> The pl/sql block contains the following section:&#8211;</p>
<p>&#8212;&#8211;The DECLARE section.<br />
&#8212;&#8211;The Master BEGIN and END section that contains the EXCEPTION section.<br />
</span></p>
<p><span style="font-family: Verdana; font-size: small;"> The declare section contains declaration of memory variables, constants, cursors etc. The begin section contains sql executable statements and pl/sql executable statements. The exception section contains code to handle errors that may arise during the execution of the code block. The end declares the end of pl/sql block.</span></p>
<p><span style="font-family: Verdana; font-size: small;">A bit about it&#8217;s working. When you typed out the pl/sql block for execution. It is sent to the pl/sql engine, whee procedural statements are executed; and sql statements are sent to the sql executor in the oracle engine. Since pl/sql engine resides in the oracle engine, the codes executes smoothly and efficiently.</span></p>
<h4><span style="font-family: Verdana; font-size: small;"> PL/SQL DATA-TYPE</span></h4>
<p><span style="font-family: Verdana; font-size: small;"> This is easy since it includes almost all the data types which u have used in sql such as date, varchar, number, char etc etc&#8230; Some of the attributes such as %TYPE is also used. This attribute automatically takes in the default datatype of the sql table from which u have passed the query. We will discuss this later.</span></p>
<p><span style="font-family: Verdana; font-size: small;"> Remember in pl/sql a variable name must begin with a character and can be followed by maximum of 29 other characters. Reserved words can&#8217;t be used unless enclosed within double quotes. Variables must be seperated from each other by at least one space or by a punctuation mark. You can assign values of operator using := operator. I won&#8217;t discuss about logical comparisons operators such as &lt;, &gt; , &gt;=, NOT, TRUE, AND, OR, NULL etc since they r quite easy to understand.</span></p>
<p><span style="font-family: Verdana; font-size: small;">MOST IMPORTANT: HOW TO DISPLAY MESSAGES ON SCREEN &#8212;<br />
<span style="color: red;">DBMS_OUTPUT :</span> is a package that includes a number of procedure and functions that accumulate information in a buffer so that it can be retrieved later. These functions can also be used to display messages to the user.<br />
<span style="color: red;">PUT_LINE :</span> Put a piece of information in the package buffer followed by an end-of-line marker. It can also be used to display message to the user. Put_line expects a single parameter of character data type. If used to display a message, it is the message &#8217;string&#8217;.<br />
EG: dbms_output.put_line(x);</p>
<p><span style="color: red;">REMEMBER:</span> To display messages to the user the SERVEROUTPUT should be set to ON. SERVEROUTPUT is a sql*plus environment parameter that displays the information pased as a parameter to the PUT_LINE function.<br />
EG: SET SERVEROUTPUT ON</span></p>
<p><span style="font-family: Verdana; font-size: small;"> A bit about comments. A comment can have 2 forms i.e.<br />
&#8211; The comment line begins with a double hyphen (&#8211;). The entire line will be treated as a comment.<br />
&#8211; The C style comment such as /* i am a comment */</span></p>
<p><span style="font-family: Verdana; font-size: small;"></p>
<p></span> <span style="font-size: medium;"><br />
<hr /></span></p>
<h2><span style="font-family: Verdana; font-size: small;"> CONDITIONAL CONTROL AND ITERATIVE CONTROL AND SEQUENTIAL CONTROL</span></h2>
<p><span style="font-size: small;"> <strong><span style="font-family: Verdana;">IF and else&#8230;..</span></strong><span style="font-family: Verdana;"><br />
<span style="color: red;"> IF &#8211;Condition THEN<br />
&#8211;Action<br />
ELSEIF &#8211;Condition THEN<br />
&#8211;Action<br />
ELSE<br />
&#8211;Action<br />
END IF;</p>
<p></span><br />
<strong> SIMPLE LOOP</strong><br />
<span style="color: red;"> loop<br />
&#8211; Sequence of statements;<br />
end loop;<br />
</span><br />
the loop ends when u use EXIT WHEN statement &#8211;condition</p>
<p><strong> WHILE LOOP</strong><br />
<span style="color: red;"> While &#8211;condition<br />
loop<br />
&#8211;sequence of statements<br />
end loop;<br />
</span><br />
<strong> FOR LOOP</strong><br />
<span style="color: red;"> FOR i in 1..10<br />
loop<br />
&#8211;sequence of statements<br />
end loop;<br />
</span><br />
</span></span> <strong><span style="font-family: Verdana; font-size: small;">GOTO (sequential control)<br />
<span style="color: red;"> GOTO X;<br />
&lt;&lt; X &gt;&gt;</p>
<p></span> </span> <span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<h2><strong><span style="font-family: Verdana; font-size: small;">EXAMPLES</span> </strong></h2>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">
--ADDITION
declare
         a number;
         b number;
         c number;
begin
         a:=&amp;a;
         b:=&amp;b;
         c:=a+b;
         dbms_output.put_line('Sum of ' || a || ' and ' || b || ' is ' || c);

Here &amp; is used to take user input at runtime.....
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--SUM OF 100 NUMBERS

Declare
	a number;
	s1 number default 0;
Begin
	a:=1;
	loop
		s1:=s1+a;
		exit when (a=100);
		a:=a+1;
	end loop;
	dbms_output.put_line('Sum between 1 to 100 is '||s1);
End;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--SUM OF odd NUIMBERS USING USER INPUT...for loop
declare
        n number;
        sum1 number default 0;
        endvalue number;
begin
        endvalue:=&amp;endvalue;
        n:=1;
        for n in 1.. endvalue
        loop
             if mod(n,2)=1
             then
                  sum1:=sum1+n;
             end if
        end loop;
        dbms_output.put_line('sum = ' || sum1);
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--SUM OF 100 ODD NUMBER .. WHILE LOOP
declare
        n number;
        endvalue number;
        sum1 number default 0;
begin
        endvalue:=&amp;endvalue;
        n:=1;
        while (n &lt; endvalue)
        loop
             sum1:=sum1+n;
             n:=n+2;
        end loop;
        dbms_output.put_line('Sum of odd numbers between 1 and ' || endvalue || ' is ' || sum1);
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--CALCULATION OF NET SALARY
declare
        ename varchar2(15);
        basic number;
        da number;
        hra number;
        pf number;
        netsalary number;
begin
        ename:=&amp;ename;
        basic:=&amp;basic;

        da:=basic * (41/100);
        hra:=basic * (15/100);

        if (basic &lt; 3000)
        then
             pf:=basic * (5/100);
        elsif (basic &gt;= 3000 and basic &lt;= 5000)
        then
             pf:=basic * (7/100);
        elsif (basic &gt;= 5000 and basic &lt;= 8000)
        then
             pf:=basic * (8/100);
        else
             pf:=basic * (10/100);
        end if;
        netsalary:=basic + da + hra -pf;
        dbms_output.put_line('Employee name : ' || ename);
        dbms_output.put_line('Providend Fund : ' || pf);
        dbms_output.put_line('Net salary : ' || netsalary);
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--MAXIMUM OF 3 NUMBERS
Declare
	a number;
	b number;
	c number;
	d number;
Begin
	dbms_output.put_line('Enter a:');
	a:=&amp;a;
	dbms_output.put_line('Enter b:');
	b:=&amp;b;
	dbms_output.put_line('Enter c:');
	c:=&amp;b;
	if (a&gt;b) and (a&gt;c) then
		dbms_output.putline('A is Maximum');
	elsif (b&gt;a) and (b&gt;c) then
		dbms_output.putline('B is Maximum');
	else
		dbms_output.putline('C is Maximum');
	end if;
End;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--QUERY EXAMPLE--IS SMITH EARNING ENOUGH
declare
        s1 emp.sal %type;
begin
        select sal into s1 from emp
        where ename = 'SMITH';
        if(no_data_found)
        then
           raise_application_error
           (20001,'smith is not present');
        end if;

        if(s1 &gt; 10000)
        then
           raise_application_error
           (20002,'smith is earning enough');
        end if;

        update emp set sal=sal + 500
        where ename='SMITH';
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--PRIME NO OR NOT
DECLARE
	no NUMBER (3) := &amp;no;
	a NUMBER (4);
	b NUMBER (2);
BEGIN
	FOR i IN 2..no - 1
	LOOP
		a := no MOD i;
		IF a = 0
		THEN
			GOTO out;
		END IF;
	END LOOP;
	&lt;&gt;
	IF a = 1
	THEN
		DBMS_OUTPUT.PUT_LINE (no || ' is a prime number');
	ELSE
		DBMS_OUTPUT.PUT_LINE (no || ' is not a prime number');
	END IF;
END;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--SIMPLE EXAMPLE OF LOOP STATEMENT I.E. EXIT WHEN
Declare
a number:= 100;
begin
loop
a := a+25;
exit when a=250;
end loop;
dbms_output.put_line (to_Char(a));
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--EXAMPLE OF WHILE LOOP
Declare
i number:=0;
j number:= 0;
begin
while i &lt;=100 loop
j := j+1;
i := i +2;
end loop;
dbms_output.put_line(to_char(i));
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--EXAMPLE OF FOR LOOP
Declare
begin
for i in 1..10
loop
dbms_output.put_line(to_char(i));
end loop;
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--SEQUENTIAL CONTROL GOTO.....
declare
--takes the default datatype of the column of the table price
cost price.minprice%type;
begin
select stdprice into cost from price where prodial in (Select prodid from product where prodese = "shampoo");
if cost &gt; 7000 then
goto Upd;
end if;
&lt;&lt; Upd &gt;&gt;
Update price set minprice = 6999 where prodid=111;
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--CALCULATE THE AREA OF A CIRCLE FOR A VALUE OF RADIUS VARYING FROM 3 TO 7. STORE THE RADIUS AND THE CORRESPONDING VALUES OF CALCULATED AREA IN A TABLE AREAS.

Declare
pi constant number(4,2) := 3.14;
radius number(5);
area number(14,2);

Begin
radius := 3;
While radius &lt;=7
Loop
area := pi* power(radius,2);
Insert into areas values (radius, area);
radius:= radius+1;
end loop;
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--INVERTING A NUMBER 5639 TO 9365
Declare
given_number varchar(5) := '5639';
str_length number(2);
inverted_number varchar(5);

Begin
str_length := length(given_number);
For cntr in reverse 1..str_length
loop
inverted_number := inverted_number || substr(given_number, cntr, 1);
end loop;
dbms_output.put_line('The Given no is ' || given_number);
dbms_output.put_line('The inverted number is ' || inverted_number);
end;
</span></strong></pre>
<p><strong><span style="color: red;"><br />
<hr /></span> <span style="font-family: Verdana; font-size: small;"><br />
</span> </strong></p>
<h2><strong><span style="font-family: Verdana; font-size: small;">EXCEPTION HANDLING</span></strong></h2>
<pre><strong><span style="font-family: Verdana; font-size: small;">
Errors in pl/sql block can be handled...error handling refers to the way we handle the errors in pl/sql block so that no
crashing stuff of code takes place...This is exactly the same as we do in C++ or java..right!!
There are two type:
===&gt; predefined exceptions
===&gt; user defined exceptions
The above 2 terms are self explanatory

predefined exceptions:

No-data-found            ==   when no rows are returned
Cursor-already-open ==   when a cursor is opened in advance
Dup-val-On-index      ==   for duplicate entry of index..
Storage-error             ==   if memory is damaged
Program-error            ==   internal problem in pl/sql
Zero-divide                 ==   divide by zero
invalid-cursor             ==   if a cursor is not open and u r trying to close it
Login-denied              ==   invalid user name or password
Invalid-number          ==   if u r inserting a string datatype for a number datatype which is already declared
Too-many-rows         ==   if more rows r returned by select statement

SYNTAX

<span style="color: red;">
begin
sequence of statements;
exception
when --exception name then
sequence of statements;
end;
</span>
</span></strong></pre>
<h2><strong> <span style="font-family: Verdana; font-size: small;"> EXAMPLES</span> </strong></h2>
<p><strong><span style="font-family: Verdana; font-size: small;"><br />
</span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">
--When there is no data returned by row
declare
price item.actualprice%type;
begin
Select actual price into price from item where qty=888;
when no-data-found then
dbms_output.put_line('item missing');
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--EXAMPLE OF USER DEFINED EXCEPTION
DECLARE
 e_rec emp%ROWTYPE;
 e1 EXCEPTION;
 sal1 emp.sal%TYPE;
BEGIN
 SELECT sal INTO sal1 FROM emp WHERE deptno = 30 AND ename = 'John';
 IF sal1 &lt; 5000 THEN
  RAISE e1;
  sal1 := 8500;
  UPDATE emp SET sal = sal1 WHERE deptno = 30 AND ename = 'John';
 END IF;
 EXCEPTION
  WHEN no_data_found THEN
   RAISE_APPLICATION_ERROR (-20001, 'John is not there.');
  WHEN e1 THEN
   RAISE_APPLICATION_ERROR (-20002, 'Less Salary.');
END;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--EXAMPLE OF RAISE-APPLICATION-ERROR... THIS IS YOUR OWN ERROR STATEMENT...U RAISE
--YOUR OWN ERROR

Declare
s1 emp.sal %type;
begin
select sal into s1 from emp where ename='SOMDUTT';
if(no-data-found) then
raise_application_error(20001, 'somdutt is not there');
end if;
if(s1 &gt; 10000) then
raise_application_error(20002, 'somdutt is earing a lot');
end if;
update emp set sal=sal+500 where ename='SOMDUTT';
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--INTERESTING EG OF USER DEFINED EXCEPTIONS
Declare
zero-price exception;
price number(8);
begin
select actualprice into price from item where ordid =400;
if price=0 or price is null then
raise zero-price;
end if;
exception
when zero-price then
dbms_output.put_line('raised xero-price exception');
end;
</span></strong></pre>
<p><strong><span style="color: red;"><br />
<hr /></span> </strong></p>
<h2><strong> <span style="font-family: Verdana; font-size: small;"> CURSORS</span> </strong></h2>
<p><strong><span style="font-family: Verdana; font-size: small;"><br />
</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">Cursor is a work area in pl/sql which is used by sql server used to store the result of a query. Each column value is pointed using pointer. You can independently manipulate cursor values. A bit about it&#8217;s working&#8230;.. suppose u ask for a query stored in the server &#8230; at first a cursor consisting of query result is created in server&#8230;now the cursor is transferred to the client where again cursor is created and hence the result is displayed&#8230;&#8230;</span> </strong></p>
<p><strong> <span style="font-family: Verdana; font-size: small;"> Cursors are of 2 types:<span style="color: red;"> implicit and explicit</span>&#8230;&#8230;.implicit cursors are created by oracle engine itself while explicit cursors are created by the users&#8230;&#8230;cursors are generally used in such a case when a query returns more than one rows&#8230;.normal pl/sql returning more than one rows givens error but using cursor this limitation can be avoided&#8230;.so cursors are used&#8230;.</span> </strong></p>
<pre><strong><span style="font-family: Verdana; font-size: small;">
cursor attributes

%ISOPEN   == returns true if ursor is open, false otherwise
%FOUND   == returns true if recod was fetched successfully, false otherwise
%NOTFOUND  == returns true if record was not fetched successfully, false otherwise
%ROWCOUNT == returns number of records processed from the cursor.</span></strong></pre>
<p><strong><span style="font-family: Verdana; font-size: small;"></p>
<p></span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">Very important: Cursor can be controlled using following 3 control statements. They are Open, Fetch, Close&#8230;..open statement identifies the active set&#8230;i.e. query returned by select statement&#8230;close statement closes the cursor&#8230;and fetch statement fetches rows into the variables&#8230;Cursors can be made into use using cursor for loop and fetch statement&#8230;we will see the corresponding examples&#8230;</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;"></p>
<p></span> </strong></p>
<h2><strong><span style="font-family: Verdana; font-size: small;">EXAMPLES</span></strong></h2>
<pre><strong><span style="font-size: small;"><span style="font-family: Verdana;">
</span><span style="font-family: Verdana; color: red;">
--EXAMPLE OF SQL%FOUND (IMPLICIT CURSORS)
begin
update employee set salary=salary *0.15
where emp_code = &amp;emp_code;
if sql%found then
dbms_output.put_line('employee record modified successfully');
else
dbms_output.put_line('employee no does not exist');
end if;
end;
</span></span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--EXAMPLE FOR SQL%NOTFOUND (IMPLICIT CURSORS)
begin
update employee set salary = salary*0.15 where emp_code = &amp;emp_code;
if sql%notfound then
dbms_output.put_line('employee no . does not exist');
else
dbms_output.put_line('employee record modified successfully');
end if;
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--EXAMPLE FOR SQL%ROWCOUNT (IMPLICIT CURSORS)
declare
rows_affected char(4);
begin
update employee set salary = salary*0.15 where job='programmers';
rows_affected := to_char(sql%rowcount);
if sql%rowcount &gt; 0 then
dbms_output.put_line(rows_affected || 'employee records modified successfully');
else
dbms_output.put_line('There are no employees working as programmers');
end if;
end;
</span></strong></pre>
<p><strong><span style="color: red; font-size: medium;"><br />
<hr /></span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">Syntax of explicit cursor: Cursor cursorname is sql select statement;<br />
Syntax of fetch : fetch cursorname into variable1, variable2&#8230;;<br />
Syntax of close; close cursorname;<br />
Syntax of open cursor; open cursorname;<br />
</span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--EXPLICIT CURSOR EG
DECLARE
	CURSOR c1 is SELECT * FROM emp;
	str_empno emp.empno%type;
	str_ename emp.ename%type;
	str_job emp.job%type;
	str_mgr emp.mgr%type;
	str_hiredate emp.hiredate%type;
	str_sal emp.sal%type;
	str_comm emp.comm%type;
	str_deptno emp.deptno%type;
	rno number;
BEGIN
	rno := &amp;rno;
	FOR e_rec IN c1
	LOOP
		IF c1%rowcount = rno THEN
			DBMS_OUTPUT.PUT_LINE (str_empno || ' ' || str_ename || ' ' || str_job || ' ' || str_mgr || ' ' || str_hiredate || ' ' || str_sal || ' ' || str_comm || ' ' || str_deptno);
		END IF;
	END LOOP;
END;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--ANOTHER EG DISPLAYING VALUE OF A TABLE
DECLARE
	CURSOR c1 IS SELECT  * FROM emp;
	e_rec emp%rowtype;
BEGIN
	OPEN c1;
	LOOP
		FETCH c1 INTO e_rec;
		DBMS_OUTPUT.PUT_LINE('Number: ' || ' ' || e_rec.empno);
		DBMS_OUTPUT.PUT_LINE('Name  : ' || ' ' || e_rec.ename);
		DBMS_OUTPUT.PUT_LINE('Salary: ' || ' ' || e_rec.sal);
		EXIT WHEN c1%NOTFOUND;
	END LOOP;
	CLOSE c1;
END;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">-- Display details of Highest 10 salary paid employee

DECLARE
	CURSOR c1 IS SELECT  * FROM emp ORDER BY sal DESC;
	e_rec emp%rowtype;
BEGIN
	FOR e_rec IN c1
	LOOP
		DBMS_OUTPUT.PUT_LINE('Number: ' || ' ' || e_rec.empno);
		DBMS_OUTPUT.PUT_LINE('Name  : ' || ' ' || e_rec.ename);
		DBMS_OUTPUT.PUT_LINE('Salary: ' || ' ' || e_rec.sal);
		EXIT WHEN c1%ROWCOUNT &gt;= 10;
	END LOOP;
END;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">-- EXAMPLE OF CURSOR FOR LOOP
declare cursor c1 is select * from somdutt;
begin
for outvariable in c1
loop
exit when c1%notfound;
if outvariable.age &lt; 21 then
dbms_output.put_line(outvariable.age || ' ' || outvariable.name);
end if;
end loop;
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--ref STRONG CURSORS
DECLARE
	TYPE ecursor IS REF CURSOR RETURN emp%ROWTYPE;
	ecur ecursor;
	e_rec emp%ROWTYPE;
	dn NUMBER;
BEGIN
	dn := &amp;deptno;
	OPEN ecur FOR SELECT * FROM emp WHERE deptno = dn;
	FOR e_rec IN ecur
	LOOP
		DBMS_OUTPUT.PUT_LINE ('Employee No    : ' || e_rec.empno);
		DBMS_OUTPUT.PUT_LINE ('Employee Salary: ' || e_rec.salary);
	END LOOP;
END;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--REF WEAK CURSORS
DECLARE
	TYPE tcursor IS REF CURSOR;
	tcur tcursor;
	e1 emp%ROWTYPE;
	d1 dept%ROWTYPE;
	tname VARCHAR2(20);
BEGIN
	tname := &amp;tablename;
	IF tname = 'emp' THEN
		OPEN tcur FOR SELECT * FORM emp;
		DBMS_OUTPUT.PUT_LINE ('Emp table opened.');
		close tcur;
		DBMS_OUTPUT.PUT_LINE ('Emp table closed.');
	ELSE IF tname = 'dept' THEN
		OPEN tcur FOR SELECT * FROM dept;
		DBMS_OUTPUT.PUT_LINE ('Dept table opened.');
		close tcur;
		DBMS_OUTPUT.PUT_LINE ('Emp table closed.');
	ELSE
		RAISE_APPLICATION_ERROR (-20004, 'Table name is wrong');
	END IF;
END;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--CURSOR FOR LOOP WITH PARAMETERS
Declare
Cursor c1(Dno number) is select * from emp where deptno = dno;
begin
for empree in c1(10) loop;
dbms_output.put_line(empree.ename);
end loop;
end;
</span></strong></pre>
<p><strong><span style="color: red;"><br />
<hr /></span><span style="font-family: Verdana; font-size: small;"><br />
</span> </strong></p>
<h2><strong><span style="font-family: Verdana; font-size: small;">TRIGGERS</span></strong></h2>
<p><strong> <span style="font-family: Verdana; font-size: small;"> Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired.</span></strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;"><br />
Advantages of database triggers:<br />
&#8212;&gt; Data is generated on it&#8217;s own<br />
&#8212;&gt; Replicate table can be maintained<br />
&#8212;&gt; To enforce complex integrity contraints<br />
&#8212;&gt; To edit data modifications<br />
&#8212;&gt; To autoincrement a field<br />
etc..<br />
</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">Syntax: Create or replace trigger &#8211;triggername&#8211; [before/after] [insert/pdate/delete] on &#8211;tablename&#8211; [for each satement/ for each row] [when --condition--] plus..begin.and exception</span> </strong></p>
<p><strong> <span style="font-family: Verdana; font-size: small;"> Triggers are of following type: before or after trigger &#8230;.and for each row and for each statement trigger&#8230; before trigger is fired before insert/update/delete statement while after trigger is fired after insert/update/delete statement&#8230;for each row and for each statements triggers are self explainatory..</span> </strong></p>
<pre><strong><span style="font-size: small;"><span style="font-family: Verdana;">
</span><span style="font-family: Verdana; color: red;">
</span></span></strong></pre>
<h2><strong><span style="font-family: Verdana; color: red; font-size: small;">EXAMPLE</span></strong></h2>
<p><strong><span style="font-family: Verdana; color: red; font-size: small;"> &#8212; A database trigger that allows changes to employee table only during the business hours(i.e. from 8 a.m to 5.00 p.m.) from monday to saturday. There is no restriction on viewing data from the table -CREATE OR REPLACE TRIGGER Time_Check BEFORE INSERT OR UPDATE OR DELETE ON EMP BEGIN IF TO_NUMBER(TO_CHAR(SYSDATE,&#8217;hh24&#8242;)) &lt; 10 OR TO_NUMBER(TO_CHAR(SYSDATE,&#8217;hh24&#8242;)) &gt;= 17 OR TO_CHAR(SYSDATE,&#8217;DAY&#8217;) = &#8216;SAT&#8217; OR TO_CHAR(SYSDATE,&#8217;DAY&#8217;) = &#8216;SAT&#8217; THEN RAISE_APPLICATION_ERROR (-20004,&#8217;YOU CAN ACCESS ONLY BETWEEN 10 AM TO 5 PM ON MONDAY TO FRIDAY ONLY.&#8217;); END IF; END;</span> <span style="font-size: medium;"><br />
<hr /></span> <span style="font-family: Verdana; color: red; font-size: small;"> &#8211;YOU HAVE 2 TABLES WITH THE SAME STRUCTURE. IF U DELETE A RECORD FROM ONE TABLE , IT WILL BE INSERTED IN 2ND TABLE ED TRIGGERNAME Create or replace trigger backup after delete on emp fro each row begin insert into emp/values (:old.ename,:old.job,:old.sal); end; save the file.. and then sql&gt; @ triggername</span> <span style="font-size: medium;"><br />
<hr /></span> <span style="font-family: Verdana; color: red; font-size: small;"> &#8211;To STICK IN SAL FIELD BY TRIGGER MEANS WHEN U ENTER GREATER THAN 5000, THEN THIS TRIGGER IS EXECUTED Create or replace trigger check before insert on emp for each row when (New.sal &gt; 5000); begin raise_application_error(-20000, &#8216;your no is greater than 5000&#8242;); end;</span> <span style="font-size: medium;"><br />
<hr /></span> <span style="font-family: Verdana; color: red; font-size: small;"> &#8211;NO CHANGES CAN BE DONE ON A PARTICULAR TABLE ON SUNDAY AND SATURDAY Create or replace trigger change before on emp for each row when (to_char(sysdate,&#8217;dy&#8217;) in (&#8217;SAT&#8217;,'SUN&#8217;)) begin raise_application_error(-200001, &#8216;u cannot enter data in saturnday and sunday&#8217;); end;</span> <span style="font-size: medium;"><br />
<hr /></span> <span style="font-family: Verdana; color: red; font-size: small;"> &#8211;IF U ENTER IN EMP TABLE ENAME FIELD&#8217;S DATA IN ANY CASE IT WILL BE INSERTED IN CAPITAL LETTERS&#8217;S ONLY Create or replace trigger cap before insert on emp for each row begin :New.ename = upper(:New.ename); end;</span> <span style="font-size: medium;"><br />
<hr /></span> <span style="font-family: Verdana; color: red; font-size: small;"> &#8211;A TRIGGER WHICH WILL NOT ALLOW U TO ENTER DUPLICATE VALUES IN FIELD EMPNO IN EMP TABLE Create or replace trigger dubb before insert on emp for each row Declare cursor c1 is select * from emp; x emp%rowtype; begin open c1; loop fetch c1 into x; if :New.empno = x.empno then dbms_output.put_line(&#8217;you entered duplicated no&#8217;); elseif :New.empno is null then dbms_output.put_line(&#8217;you empno is null&#8217;); end if; exit when c1%notfound; end loop; close c1; end;</span> <span style="color: red; font-size: medium;"><br />
<hr /></span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">Remember trigger can be dropped using Drop Trigger triggername ; statement&#8230;</span> <span style="font-size: medium;"><br />
<hr /></span> <span style="font-family: Verdana; font-size: small;"><br />
</span> </strong></p>
<h2><strong> <span style="font-family: Verdana; font-size: small;"> PROCEDURES AND FUNCTIONS</span></strong></h2>
<p><strong><span style="font-family: Verdana; font-size: small;">procedure is a subprogram&#8230;which consists of a set of sql statement. Procedures are not very different from functions. A procedure or function is a logically grouped set of SQL and PL/SQL statements that perform a specific task. A stored procedure or function is a named pl/sql code block that have been compiled and stored in one of the oracle engines&#8217;s system tables.</span> </strong></p>
<p><strong> <span style="font-family: Verdana; font-size: small;"> To make a procedure or function dynamic either of them can be passed parameters before execution. A procedure or function can then change the way it works depending upon the parameters passed prior to its execution.</span></strong></p>
<p><strong> <span style="font-family: Verdana; font-size: small;"> Procedures and function are made up of a <span style="color: red;"> declarative part, an executable part and an optional exception-handling part</span> </span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">A declaration part consists of declarations of variables. A executable part consists of the logic i.e. sql statements&#8230;.and exception handling part handles any error during run-time</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">The oracle engine performs the following steps to execute a procedure or funtion&#8230;.<span style="color: red;">Verifies user access, Verifies procedure or funtion validity and executes the procedure or function</span>. Some of the advantages of using procedures and functions are: <span style="color: red;">security, performance, memory allocation, productivity, integrity</span>.</span> </strong></p>
<p><strong><span style="font-size: small;"><span style="font-family: Verdana;">Most important the difference between procedures and functions: </span><span style="font-family: Verdana; color: red;"> A function must return a value back to the caller. A function can return only one value to the calling pl/sql block. By defining multiple out parameters in a procedure, multiple values can be passed to the caller. The out variable being global by nature, its value is accessible by any pl/sql code block including the calling pl/sql block.</span></span></strong></p>
<p><strong><span style="font-family: Verdana; color: red; font-size: small;"><br />
</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;"> Syntax for stored procedure:<br />
CREATE OR REPLACE PROCEDURE [schema] procedurename (argument { IN, OUT, IN OUT} data type, ..) {IS, AS}<br />
variable declarations; constant declarations; BEGIN<br />
pl/sql subprogram body;<br />
EXCEPTION<br />
exception pl/sql block;<br />
END;</p>
<p>Syntax for stored function:<br />
CREATE OR REPLACE FUNCTION[schema] functionname(argument IN data type, ..) RETURN data type {IS, AS}<br />
variable declarations; constant declarations; BEGIN<br />
pl/sql subprogram body;<br />
EXCEPTION<br />
exception pl/sql block;<br />
END;<br />
</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;"><br />
</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;"> The above syntax i think is self explainatory&#8230;but i will give u some details&#8230;IN : specifies that a value for the argument must be specified when calling the procedure or function. argument : is the name of an argument to the procedure or function. parentheses can be omitted if no arguments are present. OUT : specifies that the procedure passes a value for this argument back to its calling environment after execution. IN OUT : specifies that a value for the argument must be specified when calling the procedure and that the procedure passes a value for this argument back to its calling environment after execution. By default it takes IN. Data type : is the data type of an argument.</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;"><br />
</span> </strong></p>
<h2><strong><span style="font-family: Verdana; font-size: small;">EXAMPLES</span> </strong></h2>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">

--PROCEDURE USING NO ARGUMENT..AND USING CURSOR
CREATE OR REPLACE PROCEDURE P2 IS
cursor cur1 is select * from emp;
begin
for erec in cur1
loop
dbms_output.put_line(erec.ename);
end loop;
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--PROCEDURE USING ARGUMENT
CREATE OR REPLACE PROCEDURE ME( X IN NUMBER) IS
BEGIN
dbms_output.put_line(x*x);
end;

sql&gt; exec me(3);

</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--FUNCTION using argument
CREATE OR REPLACE FUNCTION RMT(X IN NUMBER) RETURN NUMBER IS
BEGIN
dbms_output.put_line(x*x);
--return (x*x);
end;

(make a block like this to run it.....)
begin
dbms_output.put_line(rmt(3));
end;

</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--CREATE A PROCEDURE THAT DELETE ROWS FROM ENQUIRY
--WHICH ARE 1 YRS BEFORE

Create or replace procedure myprocedure is begin
delete from enquiry where enquirydate &lt;= sysdate - 1;
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--CREATE A PROCEDURE THAT TAKES ARGUMENT STUDENT NAME,
--AND FIND OUT FEES PAID BY THAT STUDENT

CREATE or REPLACE procedure me (namee in varchar) is
cursor c1 is select a.feespaiddate from feespaid a, enrollment b, enquiry c
where
c.enquiryno = b.enquiryno and
a.rollno = b.rollno and
c.fname = namee;
begin
for erec in c1
loop
dbms_output.put_line(erec.feespaiddate);
end loop;
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--SUM OF 2 NOS
CREATE or replace procedure p1 is
Declare
 a number;
 b number;
 c number;
Begin
 a:=50;
 b:=89;
 c:=a+b;
 dbms_output.put_line('Sum of '||a||' and '||b||' is '||c);
End;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--DELETION PROCEDURE
create or replace procedure myproc is
begin
delete from enquiry where fname='somdutt';
end;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--IN and OUT procedure example
Create or replace procedure lest ( a number, b out number) is
identify number;
begin
select ordid into identity from item where
itemid = a;
if identity &lt; 1000 then
b := 100;
end if;
end l
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--in out parameter eg
Create or replace procedure sample ( a in number, b in out number) is
identity number;
begin
select ordid, prodid into identity, b from item where itemid=a;
if b&lt;600 then
b := b + 100;
end if;
end;

now procedure is called by passing parameter

declare
a number;
b number;
begin
sample(3000, b)
dbms_output.put_line(1th value of b is 11 b);
end ;
</span></strong></pre>
<p><strong><span style="font-size: medium;"><br />
<hr /></span> </strong></p>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">--SIMILAR EG AS BEFORE
create or replace procedure getsal( sal1 in out number) is
begin
select sal into sal1 from emp
where empno =  sal1;
end ;

now use the above in plsql block

declare
sal1 number := 7999;
begin
getsal(sal1);
dbms_output.put_line('The employee salary is' || sal1);
end ;

</span></strong></pre>
<p><strong><span style="color: red;"><br />
<hr /></span> </strong></p>
<p><strong> <span style="font-family: Verdana; font-size: small;"> u can make a procedure and functions similarly&#8230;..also if u wanna drop a function then use drop function functionname and for procedure use drop procedure procedurename</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;"></p>
<p></span> </strong></p>
<h2><strong> <span style="font-family: Verdana; font-size: small;"> PACKAGES</span> </strong></h2>
<p><strong><span style="font-family: Verdana; font-size: small;"><br />
</span> </strong></p>
<p><strong> <span style="font-family: Verdana; font-size: small;"> A package is an oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions, variables, constants, cursors and exceptions. Packages in plsql is very much similar to those packages which we use in JAVA&#8230;&#8230;yeah!! java packages holds numerous classes..right!!!&#8230;</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">A package has 2 parts&#8230;..<span style="color: red;"> package specification and package body</span><br />
</span> </strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;">A package specification part consists of all sort of declaration of functions and procedures while package body consists of codings and logic of declared functions and procedures&#8230;</span></strong></p>
<p><strong><span style="font-family: Verdana; font-size: small;"></p>
<p></span> </strong></p>
<h2><strong><span style="font-family: Verdana; font-size: small;">EXAMPLE</span></strong></h2>
<pre><strong><span style="font-family: Verdana; color: red; font-size: small;">
--SIMPLEST EG

--specification
create or replace package pack2 is
function rmt(x in number) return number;
procedure rmt1(x in number);
end;

--body
create or replace package body pack2 is
function rmt(x in number) return number is
begin
return (x*x);
end;

procedure rmt1(x in number) is
begin
dbms_output.put_line(x*x);
end;
end;

(how to run.....)
exec packagename.procedurename
i.e.
exec pack2.rmt1(3);
</span></strong></pre>
<p><strong><span style="color: red;"><br />
<hr /></span> </strong></p>
<p><strong> <span style="font-family: Verdana; font-size: small;"> As shown above u can put in complicated procedures and functions inside the package&#8230;I have just shown a simple example&#8230;u can easily modify the above code to fit your requirement&#8230;&#8230;Just try out packages which includes cursors, procedures and functions..etc..Remeber pl/sql supports overloading&#8230;i.e. u can use the same function or procedure name in your application but with different no or type of arguments..</span> </strong></p>
<p><strong><span style="font-size: medium;"> </span></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/plsql-everything-by-somdutt-ganguly/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SCJP Mock Exam</title>
		<link>http://www.javaprogrammingworld.com/scjp-mock-exam/</link>
		<comments>http://www.javaprogrammingworld.com/scjp-mock-exam/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 13:33:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SCJP Mock Exam]]></category>

		<guid isPermaLink="false">http://pimp.com/?p=94</guid>
		<description><![CDATA[QUESTION1

  You have the following code in a file called Test.java

    class Base{
       public static void main(String[] args){
       System.out.println("Hello");
       }
    }

    public class Test extends Base{}

  [...]]]></description>
			<content:encoded><![CDATA[<pre>QUESTION1

  You have the following code in a file called Test.java

    class Base{
       public static void main(String[] args){
       System.out.println("Hello");
       }
    }

    public class Test extends Base{}

   What will happen if you try to compile and run this?

1. It will fail to compile.
2. Runtime error
3. Compiles and runs with no output.
4. Compiles and runs printing "Hello"

ANS : 4

 Correct answer/s : 4
 This will compile and print "Hello"
 The entry point for a standalone java program is
 the main method of the class that is being run.
 The java runtime system will look for that method
 in class Test and find that it does have such a method.
 It does not matter whether it is defined in the class itself
 or is inherited from a parent class.   

QUESTION2

         What is the result of trying to compile and run the following code.
         public final static void main(String[] args){
         double d = 10.0 / -0;
          if(d == Double.POSITIVE_INFINITY)
           System.out.println("Positive infinity");
           else
           System.out.println("Negative infinity");
         }

1. output Positive infinity
2. output Negative infinity
3. Will fail to compile
4. Runtime exception

ANS : 1

    Corr answer : 1
    There is no such thing as a positive or negative zero.
    Hence the result is always positive infinity.

QUESTION3

   What is the result that will be printed out ?
     void aMethod()
     {
     float f = (1 / 4) * 10;
     int i = Math.round(f);
     System.out.println(i);
     }

1.    2
2.    0
3.    3
4.    2.5
5.    25

ANS : 2
   Corr Answer : 2
   The result of 1/4 will be zero because integer
   divion is carried out on the operands.
   If you need to obtain a fractional value
   you need to use either a float or double literal
   as in 1F / 4F.

QUESTION4

  Which of the following are valid declarations?

   Note : None of the literals used here
          contain the character O they are all zeroes.

1. int i     = 0XCAFE;
2. boolean b = 0;
3. char c    = 'A';
4. byte b    = 128;
5. char c    = "A";

ANS : 1,3

    Correct answer/s :1,3
   1. is correct as it is a valid hexadecimal number.2. is  wrong
   because you can only assign the values true and false to them
   4 is wrong because 128 is beyond the range of a byte. 5is wrong
   because "A" is not a char it is a String. 

QUESTION5

  What is the result of trying to compile and run this program.
    public class Test{
       public static void main(String[] args){
        int[] a = {1};
        Test t = new Test();
        t.increment(a);
        System.out.println(a[a.length - 1]);
       }
       void increment(int[] i){
       i[i.length - 1]++;
       }
    }

1. Compiler error.
2. Compiles and runs printing out 2
3. Compiles and runs printing out 1
4. An ArrayIndexOutOfBounds Exception at runtime

ANS : 2

  Correct answer/s : 2
  You are passing a reference to an array as
  the argument to the method. The method may not
  modify the passed object reference but it can modify
  the object itself.  

QUESTION6

   What will happen if you try to compile and run this ?
   public class Test{
      static{
       print(10);
       }
     static void print(int x){
       System.out.println(x);
       System.exit(0);
      }
    }

1. Compiler error.
2. Will throw a NoSuchMethod error at runtime.
3. It will compile and run printing out "10"
4. It will run with no output.
5. It will run and print "10" and then crash with an error.      

ANS : 3

    Correct answer : 3
    This will run, print a message and terminate gracefully.
    The runtime system needs to load the class before it can look
    for the main method. So the static initializer will run first
    and print "10". Immediately after that System.exit(0) will be called
    terminating the program before an error can be thrown. 

QUESTION7

      Is this legal?
      long longArr[];
      int intArr[] = { 7 ,8 , 9};
      longArr = intArr;

1. Yes
2. No

ANS : 2

    Correct answer : 2
   You cannot assign a reference to an array of primitives
   to another unless they contain the same primitive types. 

QUESTION8

   True or False.
   The range of a byte is from  -127 to 128

1. True
2. False

ANS : 2

   Correct answer/s : 2
   The statement is false. The range of an array
   is from  - 128 to 127 

QUESTION9

   Identify the valid assignments.

1. float f  = \u0038;
2. long L2 = 2L;
3. float f  = 1.2;
4. char c = '/u004E';
5. byte b = 100;

ANS : 1,2,4,5

   Corr answer : 1, 2, 5.
    1 is correct because \u0038 is unicode for nbr 8.
    3 is wrong because 1.2 is a double literal.
    4. is a little sneaky perhaps. The
       unicode escape character is incorrect

QUESTION10

        What is the result of trying to compile and run the following code.
         public static void main(String[] args){
         double d = 10 / 0;
         if(d == Double.POSITIVE_INFINITY)
           System.out.println("Positive infinity");
         else
           System.out.println("Negative infinity");
         }

1. output Positive infinity
2. output Negative infinity
3. Will fail to compile
4. Runtime exception

ANS : 4

  Corr answer : 4
   Division by zero on integer literals will throw
   a runtime error.</pre>
<p class="MsoNormal">
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 1</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which colour is used to indicate instance methods  				in the standard &#8220;javadoc&#8221; format documentation:</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">blue </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">red </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">purple </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">orange</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 2</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What is the correct ordering for the import,  				class and package declarations when found in a single file?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">package, import, class </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">class, import, package </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">import, package, class </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">package, class, import</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 3</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which methods can be legally applied to a string  				object?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">equals(String) </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">equals(Object) </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">trim() </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">round() </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">E.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">toString()</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 4</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What is the parameter specification for the  				public static void main method?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">String args [] </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">String [] args </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Strings args [] </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">String args</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 5</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What does the zeroth element of the string array  				passed to the public static void main method contain?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The name of the program </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The number of arguments </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The first argument if one is present</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 6</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following are Java keywords?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">goto </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">malloc </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">extends </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">FALSE</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 7</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What will be the result of compiling the  				following code:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public class Test {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public static void main (String args []) {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">int age;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">age = age + 1;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.println(&#8221;The age is &#8221; + age);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Compiles and runs with no output </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Compiles and runs printing out </span><em> <span style="font-size: x-small;">The age is 1 </span></em></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Compiles but generates a runtime error </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Does not compile </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">E.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Compiles but generates a compile time error</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 8</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of these is the correct format to use to  				create the literal char value <em>a</em>?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">�a� </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&#8220;a&#8221; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">new Character(a) </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">\000a</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 9</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What is the legal range of a byte integral type?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">0 - 65, 535 </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">(�128) � 127 </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">(�32,768) � 32,767 </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">(�256) � 255</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 10</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following is illegal:</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">int i = 32; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">float f = 45.0; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">double d = 45.0;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 11</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What will be the result of compiling the  				following code:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public class Test {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">static int age;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public static void main (String args []) {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">age = age + 1;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.println(&#8221;The age is &#8221; + age);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Compiles and runs with no output </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Compiles and runs printing out </span><em> <span style="font-size: x-small;">The age is 1 </span></em></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Compiles but generates a runtime error </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Does not compile </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">E.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Compiles but generates a compile time error</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 12</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following are correct?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">128 &gt;&gt; 1 gives 64 </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">128 &gt;&gt;&gt; 1 gives 64 </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">128 &gt;&gt; 1 gives �64 </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">128 &gt;&gt;&gt; 1 gives �64</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 13</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following return true?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&#8220;john&#8221; == &#8220;john&#8221; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&#8220;john&#8221;.equals(&#8221;john&#8221;) </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&#8220;john&#8221; = &#8220;john&#8221; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&#8220;john&#8221;.equals(new Button(&#8221;john&#8221;))</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 14</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following do not lead to a runtime  				error?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&#8220;john&#8221; + &#8221; was &#8221; + &#8221; here&#8221; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&#8220;john&#8221; + 3 </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">3 + 5 </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">5 + 5.5</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 15</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following are so called &#8220;short  				circuit&#8221; logical operators?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&amp; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">|| </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">&amp;&amp; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">|</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 16</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following are acceptable?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Object o = new Button(&#8221;A&#8221;); </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Boolean flag = true; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Panel p = new Frame(); </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Frame f = new Panel(); </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">E.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Panel p = new Applet();</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 17</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What is the result of compiling and running the  				following code:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public class Test {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">static int total = 10;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public static void main (String args []) {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">new Test();</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public Test () {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.println(&#8221;In test&#8221;);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.println(this);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">int temp = this.total;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">if (temp &gt; 5) {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.println(temp);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The class will not compile </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The compiler reports and error at line 2 </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The compiler reports an error at line 9 </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The value 10 is one of the elements printed to  				the standard output </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">E.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The class compiles but generates a runtime error</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q 18</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following is correct:</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">String temp [] = new String {&#8221;j&#8221; &#8220;a&#8221; &#8220;z&#8221;}; </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">String temp [] = { &#8220;j &#8221; &#8221; b&#8221; &#8220;c&#8221;}; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">String temp = {&#8221;a&#8221;, &#8220;b&#8221;, &#8220;c&#8221;}; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">String temp [] = {&#8221;a&#8221;, &#8220;b&#8221;, &#8220;c&#8221;};</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 19</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What is the correct declaration of an abstract  				method that is intended to be public:</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">public abstract void add(); </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">public abstract void add() {} </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">public abstract add(); </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">public virtual add();</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 20</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Under what situations do you obtain a default  				constructor?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">When you define any class </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">When the class has no other constructors </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">When you define at least one constructor</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 21</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Given the following code:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public class Test {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">�</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following can be used to define a  				constructor for this class:</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">public void Test() {�} </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">public Test() {�} </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">public static Test() {�} </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">public static void Test() {�}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 22</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following are acceptable to the Java  				compiler:</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">if (2 == 3) System.out.println(&#8221;Hi&#8221;); </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">if (2 = 3) System.out.println(&#8221;Hi&#8221;); </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">if (true) System.out.println(&#8221;Hi&#8221;); </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">if (2 != 3) System.out.println(&#8221;Hi&#8221;); </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">E.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">if (aString.equals(&#8221;hello&#8221;))  				System.out.println(&#8221;Hi&#8221;);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 23</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Assuming a method contains code which may raise  				an Exception (but not a RuntimeException), what is the correct  				way for a method to indicate that it expects the caller to  				handle that exception:</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">throw Exception </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">throws Exception </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">new Exception </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Don&#8217;t need to specify anything</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 24</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What is the result of executing the following  				code, using the parameters 4 and 0:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public void divide(int a, int b) {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">try {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">int c = a / b;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">} catch (Exception e) {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.print(&#8221;Exception &#8220;);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">} finally {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.println(&#8221;Finally&#8221;);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Prints out: Exception Finally </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Prints out: Finally </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Prints out: Exception </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">No output</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q.25</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following is a legal return type of  				a method overloading the following method:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public void add(int a) {�}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">void </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">int </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Can be anything</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q.26 </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which of the following statements is correct for  				a method which is overriding the following method:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public void add(int a) {�}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">the overriding method must return void </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">the overriding method must return int </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">the overriding method can return whatever it  				likes</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 27 </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Given the following classes defined in separate  				files:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">class Vehicle {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public void drive() {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.println(&#8221;Vehicle: drive&#8221;);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">class Car extends Vehicle {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public void drive() {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">System.out.println(&#8221;Car: drive&#8221;);</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public class Test {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">public static void main (String args []) {</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Vehicle v;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Car c;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">v = new Vehicle();</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">c = new Car();</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">v.drive();</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">c.drive();</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">v = c;</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">v.drive();</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">}</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What will be the effect of compiling and running  				this class Test?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Generates a Compiler error on the statement v= c; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Generates runtime error on the statement v= c; </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Prints out: </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Vehicle: drive</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Car: drive</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Car: drive</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Prints out:</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Vehicle: drive</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Car: drive</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Vehicle: drive</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 28</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Where in a constructor, can you place a call to a  				constructor defined in the super class?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Anywhere </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The first statement in the constructor </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The last statement in the constructor </span> </span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">You can&#8217;t call super in a constructor</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 29</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Which variables can an inner class access from  				the class which encapsulates it?</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">All static variables </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">All final variables </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">All instance variables </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Only final instance variables </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">E.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Only final static variables</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select all correct answers.</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;"> </span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Q. 30</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">What class must an inner class extend:</span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">A.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The top level class </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">B.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">The Object class </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">C.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">Any class or interface </span></span></p>
<p class="MsoNormal" style="text-indent: -0.25in; margin-left: 0.5in;"><span style="font-size: x-small;"><span style="font-family: Verdana;">D.</span></span><span style="font-style: normal; font-variant: normal; font-weight: normal; font-family: Times New Roman;"><span style="font-size: x-small;"> </span></span><span style="font-family: Verdana;" dir="ltr"> <span style="font-size: x-small;">It must extend an interface</span></span></p>
<p class="MsoNormal"><span style="font-family: Verdana;"> <span style="font-size: x-small;">Select the most appropriate answer.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/scjp-mock-exam/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java Quiz 2</title>
		<link>http://www.javaprogrammingworld.com/java-quiz-2/</link>
		<comments>http://www.javaprogrammingworld.com/java-quiz-2/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 20:08:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SCJP Mock Exam]]></category>

		<guid isPermaLink="false">http://pimp.com/?p=92</guid>
		<description><![CDATA[Java Multiple Choice Questions ( 11 - 20 )
Question 11.
public class AQuestion{
	private int i = giveMeJ();
	private int j = 10;
	private int giveMeJ(){
		return j;
	}
	public static void main(String args[]){
		System.out.println((new AQuestion()).i);
	}
}
Answers
1. Compiler error complaining about access restriction of  				private variables of AQuestion.
2. Compiler error complaining about forward referencing.
3. No Compilation error - The output is 0;
4. No [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Java Multiple Choice Questions ( 11 - 20 )</p>
<p></strong>Question 11.</p>
<pre>public class AQuestion{
	private int i = giveMeJ();
	private int j = 10;
	private int giveMeJ(){
		return j;
	}
	public static void main(String args[]){
		System.out.println((new AQuestion()).i);
	}
}</pre>
<p>Answers<br />
1. Compiler error complaining about access restriction of  				private variables of AQuestion.<br />
2. Compiler error complaining about forward referencing.<br />
3. No Compilation error - The output is 0;<br />
4. No Compilation error - The output is 10;</p>
<p>Question 12.</p>
<pre>public class AQuestion{
	public static void main(String args[]){
		System.out.println("Before Try");
		try{
		}
		catch(Throwable t){
			System.out.println("Inside Catch");
		}
			System.out.println("At the End");
		}
}</pre>
<p>1. Compiler error complaining about the catch block, where no  				Throwable object can ever be thrown.<br />
2. Compiler error - Throwable Object can not be caught, only  				Exceptions must be caught.<br />
3. No compiler error. The lines &#8220;Before Try&#8221; and &#8220;At the end&#8221;  				are printed on the screen.</p>
<p>Question 13.</p>
<pre>public class AQuestion{
	public static void main(String args[]){
		System.out.println("Before Try");
		try{
		}
		catch(java.io.IOException t){
			System.out.println("Inside Catch");
		}
			System.out.println("At the End");
	}
}</pre>
<p>1. Compiler error complaining about the catch block where no  				IOException object can ever be thrown.<br />
2. Compiler error - IOException not found. It must be imported  				in the first line of the code.<br />
3. No compiler error. The lines &#8220;Before Try&#8221; and &#8220;At the end&#8221;  				are printed on the screen.</p>
<p>Question 14.<br />
The class java.lang.Exception<br />
i. Is public<br />
ii. Extends Throwable<br />
iii. Implements Throwable<br />
iv. Is serializable</p>
<p>Question 15.<br />
Read this piece of code carefully</p>
<pre>if("String".trim() == "String".trim())
	System.out.println("Equal");
else
	System.out.println("Not Equal");</pre>
<p>Answers<br />
1. the code will compile an print &#8220;Equal&#8221;.<br />
2. the code will compile an print &#8220;Not Equal&#8221;.<br />
3. the code will cause a compiler error</p>
<p>Question 16.<br />
Read this piece of code carefully</p>
<pre>if( "STRING".toUpperCase() == "STRING")
	System.out.println("Equal");
else
	System.out.println("Not Equal");</pre>
<p>Answers<br />
1. the code will compile an print &#8220;Equal&#8221;.<br />
2. the code will compile an print &#8220;Not Equal&#8221;.<br />
3. the code will cause a compiler error</p>
<p>Question 17.<br />
The following lines of code<br />
byte b = 0;<br />
b += 1;<br />
1. results in b having the value 1.<br />
2. causes a compiler error.<br />
3. will require a cast (byte) before 1.</p>
<p>Question 18.<br />
The following express<br />
char c = -1;<br />
1. will cause a compiler error as the range of character is  				between 0 and 2^16 - 1. Will request for an explicit cast.<br />
2. will not cause a compiler error and c will have the value -1;<br />
3. c will not represent any ASCII character.<br />
4. c will still be a Unicode character.</p>
<p>Question 19.<br />
Which of the following statements are true?<br />
1. A method can throw an Exception<br />
2. A method can return an Exception</p>
<p>Question 20.<br />
All the wrapper classes (Integer, Boolean, Float, Short, Long,  				Double and Character)<br />
1. are public<br />
2. are serializable<br />
3. are immutatable<br />
4. extend java.lang.Number<br />
5. are final</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/java-quiz-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java Quiz 1</title>
		<link>http://www.javaprogrammingworld.com/java-quiz-1/</link>
		<comments>http://www.javaprogrammingworld.com/java-quiz-1/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 20:07:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[SCJP Mock Exam]]></category>

		<guid isPermaLink="false">http://pimp.com/?p=90</guid>
		<description><![CDATA[Java Multiple Choice Questions ( 1 - 20 )
Question 1.
Read this piece of code carefully
if("String".toString() == "String")
	System.out.println("Equal");
else
	System.out.println("Not Equal");
Answers
1. the code will compile an print &#8220;Equal&#8221;.
2. the code will compile an print &#8220;Not Equal&#8221;.
3. the code will cause a compiler error.
Question 2.
Read this piece of code carefully
if("String".trim() == "String")
	System.out.println("Equal");
else
	System.out.println("Not Equal");
Answers
1. the code will compile an print [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Java Multiple Choice Questions ( 1 - 20 )</p>
<p></strong>Question 1.<br />
Read this piece of code carefully</p>
<pre>if("String".toString() == "String")
	System.out.println("Equal");
else
	System.out.println("Not Equal");</pre>
<p>Answers<br />
1. the code will compile an print &#8220;Equal&#8221;.<br />
2. the code will compile an print &#8220;Not Equal&#8221;.<br />
3. the code will cause a compiler error.</p>
<p>Question 2.<br />
Read this piece of code carefully</p>
<pre>if("String".trim() == "String")
	System.out.println("Equal");
else
	System.out.println("Not Equal");</pre>
<p>Answers<br />
1. the code will compile an print &#8220;Equal&#8221;.<br />
2. the code will compile an print &#8220;Not Equal&#8221;.<br />
3. the code will cause a compiler error</p>
<p>Question 3.<br />
Read the code below. Will be the result of attempting to compile and run the  code below.</p>
<pre>public class AQuestion {
	public void method(Object o){
		System.out.println("Object Verion");
	}
	public void method(String s){
		System.out.println("String Version");
	}
	public static void main(String args[]){
		AQuestion question = new AQuestion();
		question.method(null);
	}
}</pre>
<p>Answers<br />
1. The code does not compile.<br />
2. The code compiles cleanly and shows &#8220;Object Version&#8221;.<br />
3. The code compiles cleanly and shows &#8220;String Version&#8221;<br />
4. The code throws an Exception at Runtime.</p>
<p>Question 4.<br />
Read the code below. Will be the result of attempting to compile and run the  code below.</p>
<pre>public class AQuestion{
	public void method(StringBuffer sb){
		System.out.println("StringBuffer Verion");
	}
	public void method(String s){
		System.out.println("String Version");
	}
	public static void main(String args[]){
		AQuestion question = new AQuestion();
		question.method(null);
	}
}</pre>
<p>Answers<br />
1. The code does not compile.<br />
2. The code compiles cleanly and shows &#8220;StringBuffer Version&#8221;.<br />
3. The code compiles cleanly and shows &#8220;String Version&#8221;<br />
4. The code throws an Exception at Runtime.</p>
<p>Question 5.<br />
Read the following code below.</p>
<pre>public interface AQuestion{
	public abstract void someMethod() throws Exception;
}</pre>
<p>A Class implementing this interface should<br />
1. Necessarily be an abstract class.<br />
2. Should have the method public abstract void someMethod();<br />
3. Should have the method public void someMethod() which has to throw an  exception which is a subclass of java.lang.Exception.<br />
4. Should have the method public void someMethod() which need not throw an  Exception.</p>
<p>Question 6.<br />
An Interface can never be private or protected.</p>
<p>Answers<br />
True<br />
False</p>
<p>Question 7.<br />
A Vector class in jdk 1.2</p>
<p>1. is public<br />
2. is final<br />
3. implements java.util.List<br />
4. is serializable<br />
5. has only One constructor</p>
<p>Question 8.<br />
A String Class</p>
<p>1. is final<br />
2. is public<br />
3. is serializable<br />
4. has a constructor which takes a StingBuffer Object as an Argument</p>
<p>Question 9.</p>
<pre>public interface AQuestion{
	void someMethod();
}</pre>
<p>The class which implements AQuestion<br />
1. Should have someMethod which must necessarily be public.<br />
2. Should have someMethod which could be &#8220;friendly&#8221; or public<br />
3. Should have someMethod which should not throw any checked exceptions.<br />
4. Should have someMethod which cannot be sychronized as sychronized is not in  the signature of the interface defination</p>
<p>Question 10.</p>
<pre>public class AQuestion{
	private int i = j;
	private int j = 10;
	public static void main(String args[]){
		System.out.println((new AQuestion()).i);
	}
}

Answers 

1. Compiler error complaining about access restriction of private variables of AQuestion. 

2. Compiler error complaining about forward referencing. 

3. No error - The output is 0; 

4. No error - The output is 10;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/java-quiz-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sun Java Certification SCJP 5.0 Objectives</title>
		<link>http://www.javaprogrammingworld.com/sun-java-certification-scjp-50-objectives/</link>
		<comments>http://www.javaprogrammingworld.com/sun-java-certification-scjp-50-objectives/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 20:05:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Sun Certified Java Programmer Resources]]></category>

		<guid isPermaLink="false">http://pimp.com/?p=88</guid>
		<description><![CDATA[Section 1: Declarations, Initialization and Scoping

* Develop code that declares classes (including abstract and all  				forms of nested classes), interfaces, and enums, and includes  				the appropriate use of package and import statements (including  				static imports).
* Develop code that declares an interface. Develop code that  				implements or extends one or more interfaces. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Section 1: Declarations, Initialization and Scoping<br />
</strong><br />
* Develop code that declares classes (including abstract and all  				forms of nested classes), interfaces, and enums, and includes  				the appropriate use of package and import statements (including  				static imports).</p>
<p>* Develop code that declares an interface. Develop code that  				implements or extends one or more interfaces. Develop code that  				declares an abstract class. Develop code that extends an  				abstract class.</p>
<p>* Develop code that declares, initializes, and uses primitives,  				arrays, enums, and objects as static, instance, and local  				variables. Also, use legal identifiers for variable names.</p>
<p>* Develop code that declares both static and non-static methods,  				and - if appropriate - use method names that adhere to the  				JavaBeans naming standards. Also develop code that declares and  				uses a variable-length argument list.</p>
<p>* Given a code example, determine if a method is correctly  				overriding or overloading another method, and identify legal  				return values (including covariant returns), for the method.</p>
<p>* Given a set of classes and superclasses, develop constructors  				for one or more of the classes. Given a class declaration,  				determine if a default constructor will be created, and if so,  				determine the behavior of that constructor. Given a nested or  				non-nested class listing, write code to instantiate the class.</p>
<p><strong>Section 2: Flow Control</strong></p>
<p>* Develop code that implements an if or switch statement; and  				identify legal argument types for these statements.</p>
<p>* Develop code that implements all forms of loops and iterators,  				including the use of for, the enhanced for loop (for-each), do,  				while, labels, break, and continue; and explain the values taken  				by loop counter variables during and after loop execution.</p>
<p>* Develop code that makes use of assertions, and distinguish  				appropriate from inappropriate uses of assertions.</p>
<p>* Develop code that makes use of exceptions and exception  				handling clauses (try, catch, finally), and declares methods and  				overriding methods that throw exceptions.</p>
<p>* Recognize the effect of an exception arising at a specified  				point in a code fragment. Note that the exception may be a  				runtime exception, a checked exception, or an error.</p>
<p>* Recognize situations that will result in any of the following  				being thrown: ArrayIndexOutOfBoundsException,ClassCastException,  				IllegalArgumentException, IllegalStateException,  				NullPointerException, NumberFormatException, AssertionError,  				ExceptionInInitializerError, StackOverflowError or  				NoClassDefFoundError. Understand which of these are thrown by  				the virtual machine and recognize situations in which others  				should be thrown programatically.</p>
<p><strong>Section 3: API Contents<br />
</strong><br />
* Develop code that uses the primitive wrapper classes (such as  				Boolean, Character, Double, Integer, etc.), and/or autoboxing &amp;  				unboxing. Discuss the differences between the String,  				StringBuilder, and StringBuffer classes.</p>
<p>* Given a scenario involving navigating file systems, reading  				from files, or writing to files, develop the correct solution  				using the following classes (sometimes in combination), from  				java.io: BufferedReader,BufferedWriter, File, FileReader,  				FileWriter and PrintWriter.</p>
<p>* Develop code that serializes and/or de-serializes objects  				using the following APIs from java.io: DataInputStream,  				DataOutputStream, FileInputStream, FileOutputStream,  				ObjectInputStream, ObjectOutputStream and Serializable.</p>
<p>* Use standard J2SE APIs in the java.text package to correctly  				format or parse dates, numbers, and currency values for a  				specific locale; and, given a scenario, determine the  				appropriate methods to use if you want to use the default locale  				or a specific locale. Describe the purpose and use of the  				java.util.Locale class.</p>
<p>* Write code that uses standard J2SE APIs in the java.util and  				java.util.regex packages to format or parse strings or streams.  				For strings, write code that uses the Pattern and Matcher  				classes and the String.split method. Recognize and use regular  				expression patterns for matching (limited to: . (dot), * (star),  				+ (plus), ?, \d, \s, \w, [], ()). The use of *, +, and ? will be  				limited to greedy quantifiers, and the parenthesis operator will  				only be used as a grouping mechanism, not for capturing content  				during matching. For streams, write code using the Formatter and  				Scanner classes and the PrintWriter.format/printf methods.  				Recognize and use formatting parameters (limited to: %b, %c, %d,  				%f, %s) in format strings.</p>
<p><strong>Section 4: Concurrency<br />
</strong><br />
* write code to define, instantiate, and start new threads using  				both java.lang.Thread and java.lang.Runnable.</p>
<p>* Recognize the states in which a thread can exist, and identify  				ways in which a thread can transition from one state to another.</p>
<p>* Given a scenario, write code that makes appropriate use of  				object locking to protect static or instance variables from  				concurrent access problems.</p>
<p>* Given a scenario, write code that makes appropriate use of  				wait, notify, or notifyAll.</p>
<p><strong>Section 5: OO Concepts<br />
</strong><br />
* Develop code that implements tight encapsulation, loose  				coupling, and high cohesion in classes, and describe the  				benefits.</p>
<p>* Given a scenario, develop code that demonstrates the use of  				polymorphism. Further, determine when casting will be necessary  				and recognize compiler vs. runtime errors related to object  				reference casting.</p>
<p>* Explain the effect of modifiers on inheritance with respect to  				constructors, instance or static variables, and instance or  				static methods.</p>
<p>* Given a scenario, develop code that declares and/or invokes  				overridden or overloaded methods and code that declares and/or  				invokes superclass, overridden, or overloaded constructors.</p>
<p>* Develop code that implements &#8220;is-a&#8221; and/or &#8220;has-a&#8221;  				relationships.</p>
<p><strong>Section 6: Collections / Generics<br />
</strong><br />
* Given a design scenario, determine which collection classes  				and/or interfaces should be used to properly implement that  				design, including the use of the Comparable interface.</p>
<p>* Distinguish between correct and incorrect overrides of  				corresponding hashCode and equals methods, and explain the  				difference between == and the equals method.</p>
<p>* Write code that uses the generic versions of the Collections  				API, in particular, the Set, List, and Map interfaces and  				implementation classes. Recognize the limitations of the  				non-generic Collections API and how to refactor code to use the  				generic versions.</p>
<p>* Develop code that makes proper use of type parameters in  				class/interface declarations, instance variables, method  				arguments, and return types; and write generic methods or  				methods that make use of wildcard types and understand the  				similarities and differences between these two approaches.</p>
<p>* Use capabilities in the java.util package to write code to  				manipulate a list by sorting, performing a binary search, or  				converting the list to an array. Use capabilities in the  				java.util package to write code to manipulate an array by  				sorting, performing a binary search, or converting the array to  				a list. Use the java.util.Comparator and java.lang.Comparable  				interfaces to affect the sorting of lists and arrays.  				Furthermore, recognize the effect of the &#8220;natural ordering&#8221; of  				primitive wrapper classes and java.lang.String on sorting.</p>
<p><strong>Section 7: Fundamentals<br />
</strong><br />
* Given a code example and a scenario, write code that uses the  				appropriate access modifiers, package declarations, and import  				statements to interact with (through access or inheritance) the  				code in the example.</p>
<p>* Given an example of a class and a command-line, determine the  				expected runtime behavior.</p>
<p>* Determine the effect upon object references and primitive  				values when they are passed into methods that perform  				assignments or other modifying operations on the parameters.</p>
<p>* Given a code example, recognize the point at which an object  				becomes eligible for garbage collection, and determine what is  				and is not guaranteed by the garbage collection system.  				Recognize the behaviors of System.gc and finalization.</p>
<p>* Given the fully-qualified name of a class that is deployed  				inside and/or outside a JAR file, construct the appropriate  				directory structure for that class. Given a code example and a  				classpath, determine whether the classpath will allow the code  				to compile successfully.</p>
<p>* Write code that correctly applies the appropriate operators  				including assignment operators (limited to: =, +=, -=),  				arithmetic operators (limited to: +, -, *, /, %, ++, &#8211;),  				relational operators (limited to: &lt;, &lt;=, &gt;, &gt;=, ==, !=), the  				instanceof operator, logical operators (limited to: &amp;, |, ^, !,  				&amp;&amp;, ||), and the conditional operator ( ? : ), to produce a  				desired result. Write code that determines the equality of two  				objects or two primitives.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/sun-java-certification-scjp-50-objectives/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sun Java Certification SCJP 1.4 Objectives</title>
		<link>http://www.javaprogrammingworld.com/sun-java-certification-scjp-14-objectives/</link>
		<comments>http://www.javaprogrammingworld.com/sun-java-certification-scjp-14-objectives/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 20:02:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Sun Certified Java Programmer Resources]]></category>

		<guid isPermaLink="false">http://pimp.com/?p=86</guid>
		<description><![CDATA[Section 1: Declarations and Access Control

* Write code that declares, constructs and initializes arrays of  				any base type using any of the permitted forms both for  				declaration and for initialization.
* Declare classes, nested classes, methods, instance variables,  				static variables and automatic (method local) variables making  				appropriate use of all permitted modifiers [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Section 1: Declarations and Access Control<br />
</strong><br />
* Write code that declares, constructs and initializes arrays of  				any base type using any of the permitted forms both for  				declaration and for initialization.<br />
* Declare classes, nested classes, methods, instance variables,  				static variables and automatic (method local) variables making  				appropriate use of all permitted modifiers (such as public,  				final, static, abstract, etc.). State the significance of each  				of these modifiers both singly and in combination and state the  				effect of package relationships on declared items qualified by  				these modifiers.<br />
* For a given class, determine if a default constructor will be  				created and if so state the prototype of that constructor.<br />
* Identify legal return types for any method given the  				declarations of all related methods in this or parent classes.</p>
<p><strong>Section 2: Flow control, Assertions, and Exception Handling<br />
</strong><br />
* Write code using if and switch statements and identify legal  				argument types for these statements.<br />
* Write code using all forms of loops including labeled and  				unlabeled, use of break and continue, and state the values taken  				by loop counter variables during and after loop execution.<br />
* Write code that makes proper use of exceptions and exception  				handling clauses (try, catch, finally) and declares methods and  				overriding methods that throw exceptions.<br />
* Recognize the effect of an exception arising at a specified  				point in a code fragment. Note: The exception may be a runtime  				exception, a checked exception, or an error (the code may  				include try, catch, or finally clauses in any legitimate  				combination).<br />
* Write code that makes proper use of assertions, and  				distinguish appropriate from inappropriate uses of assertions.<br />
* Identify correct statements about the assertion mechanism.</p>
<p><strong>Section 3: Garbage Collection<br />
</strong><br />
* State the behavior that is guaranteed by the garbage  				collection system.<br />
* Write code that explicitly makes objects eligible for garbage  				collection.<br />
* Recognize the point in a piece of source code at which an  				object becomes eligible for garbage collection.</p>
<p><strong>Section 4: Language Fundamentals<br />
</strong><br />
* Identify correctly constructed package declarations, import  				statements, class declarations (of all forms including inner  				classes) interface declarations, method declarations (including  				the main method that is used to start execution of a class),  				variable declarations, and identifiers.<br />
* Identify classes that correctly implement an interface where  				that interface is either java.lang.Runnable or a fully specified  				interface in the question.<br />
* State the correspondence between index values in the argument  				array passed to a main method and command line arguments.<br />
* Identify all Java programming language keywords. Note: There  				will not be any questions regarding esoteric distinctions  				between keywords and manifest constants.<br />
* State the effect of using a variable or array element of any  				kind when no explicit assignment has been made to it.<br />
* State the range of all primitive formats, data types and  				declare literal values for String and all primitive types using  				all permitted formats bases and representations.</p>
<p><strong>Section 5: Operators and Assignments<br />
</strong><br />
* Determine the result of applying any operator (including  				assignment operators and instance of) to operands of any type  				class scope or accessibility or any combination of these.<br />
* Determine the result of applying the boolean equals (Object)  				method to objects of any combination of the classes  				java.lang.String, java.lang.Boolean and java.lang.Object.<br />
* In an expression involving the operators &amp;, |, &amp;&amp;, || and  				variables of known values state which operands are evaluated and  				the value of the expression.<br />
* Determine the effect upon objects and primitive val</p>
<p><strong>Section 6: Overloading, Overriding, Runtime Type and Object  				Orientation<br />
</strong><br />
* State the benefits of encapsulation in object oriented design  				and write code that implements tightly encapsulated classes and  				the relationships &#8220;is a&#8221; and &#8220;has a&#8221;.<br />
* Write code to invoke overridden or overloaded methods and  				parental or overloaded constructors; and describe the effect of  				invoking these methods.<br />
* Write code to construct instances of any concrete class  				including normal top level classes and nested classes.</p>
<p><strong>Section 7: Threads<br />
</strong><br />
* Write code to define, instantiate and start new threads using  				both java.lang.Thread and java.lang.Runnable.<br />
* Recognize conditions that might prevent a thread from  				executing.<br />
* Write code using synchronized wait, notify and notifyAll to  				protect against concurrent access problems and to communicate  				between threads.<br />
* Define the interaction among threads and object locks when  				executing synchronized wait, notify or notifyAll.</p>
<p><strong>Section 8: Fundamental Classes in the java.lang Package<br />
</strong><br />
* Write code using the following methods of the java.lang.Math  				class: abs, ceil, floor, max, min, random, round, sin, cos, tan,  				sqrt.<br />
* Describe the significance of the immutability of String  				objects.<br />
* Describe the significance of wrapper classes, including making  				appropriate selections in the wrapper classes to suit specified  				behavior requirements, stating the result of executing a  				fragment of code that includes an instance of one of the wrapper  				classes, and writing code using the following methods of the  				wrapper classes (e.g., Integer, Double, etc.)<br />
* doubleValue<br />
* floatValue<br />
* intValue<br />
* longValue<br />
* parseXxx<br />
* getXxx<br />
* toString<br />
* toHexString</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javaprogrammingworld.com/sun-java-certification-scjp-14-objectives/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
