Close
Login to Your Account
Faadooengineers




Results 1 to 1 of 1

Thread: MCQ on Core Java with Answers

  1. #1

    Download MCQ on Core Java with Answers

    1. Which exception is thrown by the read( ) method of input stream class?

    A) Exception

    B) ClassNotFoundException

    C) read Exception

    D) IOException



    2. What garbage collection in the context of java?

    A) The operating system periodically deletes all of the java files available on the system.

    B) Any package imported in a program and not used in automatically deleted.

    C) When all references to an object are gone, the memory used by the object is automatically reclaimed.

    D) The JVM checks the output of any Java program and deletes anything that doesn't make sense.



    3. In order for a source code file, containing the public class test, to successfully compile, which of the following must be true?

    A) It must have a package statement

    B) It must be named test.java

    C) It must import java.lang

    D) It must declare a public class named test.



    4. Which of the following are true about the Error and Exception classes?

    A) Both classes extend throwable

    B) The error class is final and exception class is not.

    C) The Exception class is final and the Error is not.

    D) Both classes implement Throwable



    5. Which of the following are true?

    A) The void class extends the class class

    B) The float class extends double class

    C) The system class extends the runtime class

    D) The integer class extends the number class



    6. How do you create a Reader object from an InputStream object?

    A) Use the static createReader() method of InputStream class

    B) Use the static createReader() method of Reader class

    C) Create an InputStreamReader object passing the InputStream object an an argument to the InputStreamReader constructor.

    D) Create an OutputStreamReader object, passing the InputStream object as an argument to the OutputStreamReader constructor.



    7. Which of the following is true?

    A) The event inheritance model has replaced the event delegation model

    B) The event inheritance model is more efficient than event delegation model

    C) The event delegation model uses event listeners to define the methods of event handling classes.

    D) The event delegation model uses the handleEvent() method to support event handling.



    8. Which of the following is the highest class in the event delegation model?

    A) java.util.EventListner

    B) java.util.EventObject

    C) java.util.AWTEvent

    D) java.util.event.AWTEvent



    9. When two or more objects are added as listeners for the same event, which listener is first invoked to handle the event?

    A) The first object that was added as listner.

    B) The last object that was added as listner

    C) There is no way to determine which listener will be invoked first.

    D) It is impossible to have more than one listener for a given event.



    10. Suppose that you want to have an object eh handle the TextEvent of TextArea object t. How should you add eh as the event handler for?

    A) t.addTextListener(eh);

    B) eh.addTextListner(t);

    C) addTextListner(eh.t);

    D) addTextListner(t,eh);



    11. What is the preferred way to handle an object's events in Java 2?

    A) Override the object's handleEvent( ) method.

    B) Add one or more event listeners to handle the events

    C) Have the object override its process Event( ) methods.

    D) Have the object override its dispatch Event( ) methods.



    12. Which component method is used to access a component's immediate container?

    A) getVisible()

    B) getImmediate()

    C) getParent()

    D) getContainer()



    13. Which of the following creates a List with 5 visible items and multiple selection enabled?

    A) new List(5, true)

    B) new List(true, 5)

    C) new List(5, false)

    D) new List(false, 5)



    14. An Applet has its Layout Manager set to the default of FlowLayout. What code would be the correct to change to another Layout Manager?

    A) setLayoutManager(new GridLayout());

    B) setLayout(new GridLayout(2,2));

    C) setGridLayout(2,2);

    D) setBorderLayout();



    15. How do you change the current layout manager for a container?

    A) Use the setLayout method.

    B) Once created you cannot change the current layout manager of a component

    C) Use the setLayoutManager method.

    D) Use the updateLayout method.



    16. Which of the following methods can be used to draw the outline of a square within a JAVA.awt.Component object?

    A) drawLine()

    B) fillRect()

    C) drawPolygon()

    D) drawPolygon()



    17. State true or false

    i) JPanel is a class included in awt package

    ii) Anonymous classes are mostly used for event handling

    iii) Names of anonymous classes must be unique

    iv) JOptionPane is an inner class

    A) i-false, ii-false, iii-true, iv-true

    B) i-true, ii-false, iii-true, iv-false

    C) i-false, ii-true, iii-false, iv-false

    D) i-true, ii-true, iii-false, iv-true



    18. State true or false

    i) Java RMI supports distributed objects written entirely in java

    ii) Java RMI makes use of stubs and skeleton

    iii) In Java RMI an object registers itself with a media server

    iv) IDL is interface declaration language

    A) True, True, False, False

    B) False, True, True, True

    C) True, False, True, False

    D) True, True, True, True



    19. Match the following

    a) Datagram Socket i) UDP connection

    b) URL ii) provides necessary framework of debugging java programs

    c) java.net iii) makes it possible to communicate over a network with java programs

    d) sun.tools.debug iv) is a java object that represent WWW address

    A) a-i, b-iv, c-iii, d-ii

    B) a-i, b-iv, c-ii, d-iii

    C) a-ii, b-iii, c-i, d-iv

    D) a-ii, b-i, c-iii, d-iv



    20. State true or false

    i) public can only be assigned to class

    ii) protected protects a statement

    iii) protected method is never accessible outside the package

    iv) friendly variable may be accessible outside class

    A) True, True, False, True

    B) False, False, False, True

    C) False, True, False, False

    D) True, False, False, False


    View Answers:


    1. D) IOException
    2. C) When all references to an object are gone, the memory used by the object is automatically reclaimed
    3. B) It must be named test.java
    4. A) Both classes extend throwable
    5. D) The integer class extends the number class
    6. C) Create an InputStreamReader object passing the InputStream object an an argument to the InputStreamReader constructor.
    7. C) The event delegation model uses event listeners to define the methods of event handling classes.
    8. B) java.util.EventObject
    9. C) There is no way to determine which listener will be invoked first.
    10. D) addTextListner(t,eh);
    11. B) Add one or more event listeners to handle the events
    12. C) getParent()
    13. A) new List(5, true)
    14. B) setLayout(new GridLayout(2,2));
    15. A) Use the setLayout method
    16. A) drawLine()
    17. C) i-false, ii-true, iii-false, iv-false
    18. A) True, True, False, False
    19. A) a-i, b-iv, c-iii, d-ii
    20. A) True, True, False, True







    1. The JDBC-ODBC bridge allows ……….. to be used as ………..
    A) JDBC drivers, ODBC drivers
    B) Drivers, Application
    C) ODBC drivers, JDBC drivers
    D) Application, drivers

    2. Which of the following is true about Java.
    A) Java does not support overloading.
    B) Java has replaced the destructor function of C++
    C) There are no header files in Java.
    D) All of the above.

    3. ……………. are not machine instructions and therefore, Java interpreter generates machine code that can be directly executed by the machine that is running the Java program.
    A) Compiled Instructions
    B) Compiled code
    C) byte code
    D) Java mid code

    4. The command javac
    A) Converts a java program into binary code
    B) Converts a java program into bytecode
    C) Converts a java program into machine language
    D) None of the above.

    5. Which of the following is not the java primitive type
    A) Byte
    B) Float
    C) Character
    D) Long double

    6. Command to execute compiled java program is
    A) java
    B) javac
    C) run
    D) javaw

    7. Java Servlet
    i) is key component of server side java development
    ii) is a small pluggable extension to a server that enhances functionality
    iii) runs only in Windows Operating System
    iv) allows developers to customize any java enabled server
    A) i, ii & iii are ture
    B) i, iii & iv are true
    C) ii, iii & iv are true
    D) i, ii & iv are true

    8. Inner classes are
    A) anonymous classes
    B) nested classes
    C) sub classes
    D) derived classes

    9. How many times does the following code segment execute
    int x=1, y=10, z=1;
    do{y--; x++; y-=2; y=z; z++} while (y>1 && z<10);
    A) 1
    B) 10
    C) 5
    D) infinite

    10. State weather the following statement is true or false for EJB.
    1. EJB exists in the middle-tier
    2. EJB specifies an execution environment
    3. EJB supports transaction processing
    A) 1-true, 2. true, 3. true
    B) 1- true, 2. false, 3. true
    C) 1- false, 2- false, 3- false
    D) 1-true, 2-true, 3-false
    Answers:


    1. C) ODBC drivers, JDBC drivers
    2. D) All of the above.
    3. C) byte code
    4. B) Converts a java ....into bytecode
    5. D) Long double
    6. A) java
    7. D) i, ii & iv are true
    8. B) nested classes
    9. A) 1
    10. A) 1-true, 2. true, 3. true











    1. All java classes are derived from
    A) java.lang.Class
    B) java.util.Name
    C) java.lang.Object
    D) java.awt.Window

    2. The jdb is used to
    A) Create a jar archive
    B) Debug a java program
    C) Create C header file
    D) Generate java documentation

    3. What would happen if "String[]args" is not included as argument in the main method.
    A) No error
    B) Compilation error
    C) Program won't run
    D) Program exit

    4. For execution of DELETE SQL query in JDBC, ............. method must be used.
    A) executeQuery()
    B) executeDeleteQuery()
    C) executeUpdate()
    D) executeDelete()

    5. Which method will a web browser call on a new applet?
    A) main method
    B) destroy method
    C) execute method
    D) init method

    6. Which of the following is not mandatory in variable declaration?
    A) a semicolon
    B) an identifier
    C) an assignment
    D) a data type

    7. When a program class implements an interface, it must provide behavior for
    A) two methods defined in that interface
    B) any methods in a class
    C) only certain methods in that interface
    D) all methods defined in that interface

    8. In order to run JSP .................... is required.
    A) Mail Server
    B) Applet viewer
    C) Java Web Server
    D) Database connection

    9. State true of false.
    i) AWT is an extended version of swing
    ii) Paint( ) of Applet class cannot be overridden
    A) i-false, ii-false
    B) i-false,ii-true
    C) i-true, ii-false
    D) i-true, ii-true

    10. Prepared Statement object in JDBC used to execute........... queries.
    A) Executable
    B) Simple
    C) High level
    D) Parameterized

    Answers:


    1.C) java.lang.Object
    2.B) Debug a java program
    3.C) Program won't run
    4.C) executeUpdate()
    5.D) init method
    6.C) an assignment
    7.D) all methods ... interface
    8.C) Java Web Server
    9.A) i-false, ii-false
    10.D) Parameterized
















    1. DBMS is a collection of ………….. that enables user to create and maintain a database.

    A) Keys

    B) Translators

    C) Program

    D) Language Activity


    2. In a relational schema, each tuple is divided into fields called

    A) Relations

    B) Domains

    C) Queries

    D) All of the above


    3. In an ER model, ……………. is described in the database by storing its data.

    A) Entity

    B) Attribute

    C) Relationship

    D) Notation


    4. DFD stands for

    A) Data Flow Document

    B) Data File Diagram

    C) Data Flow Diagram

    D) Non of the above


    5. A top-to-bottom relationship among the items in a database is established by a

    A) Hierarchical schema

    B) Network schema

    C) Relational Schema

    D) All of the above


    6. ……………… table store information about database or about the system.

    A) SQL

    B) Nested

    C) System

    D) None of these


    7. …………..defines the structure of a relation which consists of a fixed set of attribute-domain pairs.

    A) Instance

    B) Schema

    c) Program

    D) Super Key


    8. ……………… clause is an additional filter that is applied to the result.

    A) Select

    B) Group-by

    C) Having

    D) Order by


    9. A logical schema

    A) is the entire database

    B) is a standard way of organizing information into accessible parts.

    C) Describes how data is actually stored on disk.

    D) All of the above


    10. ………………… is a full form of SQL.

    A) Standard query language

    B) Sequential query language

    C) Structured query language

    D) Server side query language


    11) A relational database developer refers to a record as

    A. a criteria

    B. a relation

    C. a tuple

    D. an attribute


    12) .......... keyword is used to find the number of values in a column.

    A. TOTAL

    B. COUNT

    C. ADD

    D. SUM


    13) An advantage of the database management approach is

    A. data is dependent on programs

    B. data redundancy increases

    C. data is integrated and can be accessed by multiple programs

    D. none of the above


    14) The collection of information stored in a database at a particular moment is called as ......



    A. schema

    B. instance of the database

    C. data domain

    D. independence


    15) Data independence means

    A. data is defined separately and not included in programs.

    B. programs are not dependent on the physical attributes of data

    C. programs are not dependent on the logical attributes of data

    D. both B and C


    16) A ......... is used to define overall design of the database

    A. schema

    B. application program

    C. data definition language

    D. code


    17) Key to represent relationship between tables is called

    A. primary key

    B. secondary key

    C. foreign key

    D. none of the above


    18) Grant and revoke are ....... statements.

    A. DDL

    B. TCL

    C. DCL

    D. DML


    19) DBMS helps achieve

    A. Data independence

    B. Centralized control of data

    C. Neither A nor B

    D. Both A and B


    20) .......... command can be used to modify a column in a table

    A. alter

    B. update

    C. set

    D. create


    Answers:


    1. C) Program
    2. B) Domains
    3. A) Entity
    4. C) Data Flow Diagram
    5. A) Hierarchical schema
    6. C) System
    7. B) Schema
    8. C) Having
    9. B) is a standard .. accessible parts.
    10. C) Structured query language
    11) C. a tuple
    12) B. COUNT
    13) C. data is integrated and can be accessed by multiple programs
    14) B. instance of the database
    15) D. both B and C
    16) A. schema
    17) C. foreign key
    18) C. DCL
    19) D. Both A and B
    20) A. alter










    1. The candidate key is that you choose to identify each row uniquely is called ……………..

    A) Alternate Key

    B) Primary Key

    C) Foreign Key

    D) None of the above


    2. …………….. is used to determine whether of a table contains duplicate rows.

    A) Unique predicate

    B) Like Predicate

    C) Null predicate

    D) In predicate


    3. To eliminate duplicate rows ……………… is used

    A) NODUPLICATE

    B) ELIMINATE

    C) DISTINCT

    D) None of these


    4. State true or false

    i) A candidate key is a minimal super key.

    ii) A candidate key can also refer to as surrogate key.

    A) i-true, ii-false

    B) i-false, ii-true

    C) i-true, ii-true

    D) i-false, ii-false


    5. DCL stands for

    A) Data Control Language

    B) Data Console Language

    C) Data Console Level

    D) Data Control Level


    6. …………………… is the process of organizing data into related tables.

    A) Normalization

    B) Generalization

    C) Specialization

    D) None of the above


    7. A ………………. Does not have a distinguishing attribute if its own and mostly are dependent entities, which are part of some another entity.

    A) Weak entity

    B) Strong entity

    C) Non attributes entity

    D) Dependent entity


    8. …………….. is the complex search criteria in the where clause.

    A) Sub string

    B) Drop Table

    C) Predict

    D) Predicate


    9. ………………… is preferred method for enforcing data integrity

    A) Constraints

    B) Stored Procedure

    C) Triggers

    D) Cursors


    10. The number of tuples in a relation is called its …………. While the number of attributes in a relation is called it’s ………………..

    A) Degree, Cardinality

    B) Cardinality, Degree

    C) Rows, Columns

    D) Columns, Rows


    11) The language that requires a user to specify the data to be retrieved without specifying exactly how to get it is

    A. Procedural DML

    B. Non-Procedural DML

    C. Procedural DDL

    D. Non-Procedural DDL


    12) Which two files are used during operation of the DBMS?

    A. Query languages and utilities

    B. DML and query language

    C. Data dictionary and transaction log

    D. Data dictionary and query language


    13) The database schema is written in

    A. HLL

    B. DML

    C. DDL

    D. DCL


    14) The way a particular application views the data from the database that the application uses is a

    A. module

    B. relational model

    C. schema

    D. sub schema


    15) The relational model feature is that there

    A. is no need for primary key data

    B. is much more data independence than some other database models

    C. are explicit relationships among records.

    D. are tables with many dimensions


    16) Which one of the following statements is false?

    A. The data dictionary is normally maintained by the database administrator

    B. Data elements in the database can be modified by changing the data dictionary.

    C. The data dictionary contains the name and description of each data element.

    D. The data dictionary is a tool used exclusively by the database administrator.


    17) Which of the following are the properties of entities?

    A. Groups

    B. Table

    C. Attributes

    D. Switchboards


    18) Which database level is closest to the users?

    A. External

    B. Internal

    C. Physical

    D. Conceptual


    19) Which are the two ways in which entities can participate in a relationship?

    A. Passive and active

    B. Total and partial

    C. Simple and Complex

    D. All of the above


    20) ........ data type can store unstructured data

    A. RAW

    B. CHAR

    C. NUMERIC

    D. VARCHAR

    Answers:


    1. B. Primary Key
    2. A. Unique predicate
    3. C. DISTINCT
    4. C. i-true, ii-true
    5. A. Data Control Language
    6. A. Normalization
    7. A. Weak entity
    8. D. Predicate
    9. A. Constraints
    10. B. Cardinality, Degree
    11. B. Non-Procedural DML
    12.C. Data dictionary and transaction log
    13. C. DDL
    14. D. sub schema
    15. B. is much more data independence than some other database models
    16. B. Data elements in the database can be modified by changing the data dictionary.
    17. C. Attributes
    18. A. External
    19. B. Total and partial
    20. A. RAW
















    1. State true or false.
    i) Select operator is not a unary operator.
    ii) Project operator chooses subset of attributes or columns of a relation.

    A) i-True, ii-False

    B) i-True, ii-True

    C) i-False, ii-True

    D) i-False, ii-False


    2. …………… database is used as template for all databases created.

    A) Master

    B) Model

    C) Tempdb

    D) None of the above


    3. One aspect that has to be dealt with by the integrity subsystem is to ensure that only valid values can be assigned to each data items. This is referred to as

    A) Data Security

    B) Domain access

    C) Data Control

    D) Domain Integrity


    4. ………………….. operator is basically a join followed by a project on the attributes of first relation.

    A) Join

    B) Semi-Join

    C) Full Join

    D) Inner Join


    5. Which of the following is not a binary operator in relational algebra?

    A) Join

    B) Semi-Join

    C) Assignment

    D) Project


    6. Centralizing the integrity checking directly under the DBMS ………….. Duplication and ensures the consistency and validity of the database.

    A) Increases

    B) Skips

    C) Does not reduce

    D) Reduces


    7. Which of the following is/are the DDL statements?

    A) Create

    B) Drop

    C) Alter

    D) All of the above




    8. In snapshot, …………………. clause tells oracle how long to wait between refreshes.

    A) Complete

    B) Force

    C) Next

    D) Refresh


    9. ……………… defines rules regarding the values allowed in columns and is the standard mechanism for enforcing database integrity.

    A) Column

    B) Constraint

    C) Index

    D) Trigger


    10. For like predicate which of the following is true.
    i) % matches zero of more characters.
    ii) _ matches exactly one character.

    A) i-only

    B) ii-only

    C) Both of them

    D) None of them

    Answers:

    1. C) i-False, ii-True
    2. B) Model
    3. D) Domain Integrity
    4. B) Semi-Join
    5. D) Project
    6. D) Reduces
    7. D) All of the above
    8. D) Refresh
    9. B) Constraint
    10. C) Both of them






























    1. In SQL, which command is used to issue multiple CREATE TABLE, CREATE VIEW and GRANT statements in a single transaction?

    A) CREATE PACKAGE

    B) CREATE SCHEMA

    C) CREATE CLUSTER

    A) All of the above


    2. In SQL, the CREATE TABLESPACE is used

    A) to create a place in the database for storage of scheme objects, rollback segments, and naming the data files to comprise the tablespace.

    B) to create a database trigger.

    C) to add/rename data files, to change storage

    D) All of the above


    3. Which character function can be used to return a specified portion of a character string?

    A) INSTR

    B) SUBSTRING

    C) SUBSTR

    D) POS


    4. Which of the following is TRUE for the System Variable $date$?

    A) Can be assigned to a global variable.

    B) Can be assigned to any field only during design time.

    C) Can be assigned to any variable or field during run time.

    D) Can be assigned to a local variable.


    5. What are the different events in Triggers?

    A) Define, Create

    B) Drop, Comment

    C) Insert, Update, Delete

    D) Select, Commit


    6. Which is the subset of SQL commands used to manipulate Oracle Database Structures, including tables?

    A) Data Definition Language

    B) Data Manipulation Language

    C) Data Described Language

    D) Data Retrieval Language


    7. The SQL statement SELECT SUBSTR('123456789', INSTR('abcabcabc','b'), 4) FROM EMP; prints

    A) 6789

    B) 2345

    C) 1234

    D) 456789


    8. Which of the following SQL command can be used to modify existing data in a database table?

    A) MODIFY

    B) UPDATE

    C) CHANGE

    D) NEW


    9. When SQL statements are embedded inside 3GL, we call such a program as ..........

    A) nested query

    B) nested programming

    C) distinct query

    D) embedded SQL


    10. ................ provides option for entering SQL queries as execution time, rather than at the development stage.

    A) PL/SQL

    B) SQL*Plus

    C) SQL

    D) Dynamic SQL



    11) The RDBMS terminology for a row is

    A. tuple

    B. relation

    C. attribute

    D. degree


    12) To change column value in a table the ......... command can be used.

    A. create

    B. insert

    C. alter

    D. update


    13) The full form of DDL is

    A. Dynamic Data Language

    B. Detailed Data Language

    C. Data Definition Language

    D. Data Derivation Language


    14) To pass on granted privileges to other user the ...... clause is used

    A. create option

    B. grant option

    C. update option

    D. select option


    15) A set of possible data values is called

    A. attribute

    B. degree

    C. tuple

    D. domain


    16) ......... is critical in formulating database design.

    A. row column order

    B. number of tables

    C. functional dependency

    D. normalizing


    17) A primary key if combined with a foreign key creates

    A. Parent-Child relationship between the tables that connect them

    B. Many to many relationship between the tables that connect them

    C. Network model between the tables that connect them

    D. None of the above


    18) A ............. represents the number of entities to which another entity can be associated

    A. mapping cardinality

    B. table

    C. schema

    D. information


    19) Which two files are used during operation of the DBMS

    A. Query languages and utilities

    B. DML and query language

    C. Data dictionary and transaction log

    D. Data dictionary and query language


    20) A ........... is a set of column that identifies every row in a table.

    A. composite key

    B. candidate key

    C. foreign key

    D. super key
    Answers:


    1. B) CREATE SCHEMA
    2. A) to create a place in the database for storage of scheme objects, rollback segments, and naming the data files to comprise the table-space.
    3. C) SUBSTR
    4. B) Can be assigned to any field only during design time.
    5. C) Insert, Update, Delete
    6. A) Data Definition Language
    7. B) 2345
    8. B) UPDATE
    9. D) embedded SQL
    10.D) Dynamic SQL
    11) A. tuple
    12) D. update
    13) C. Data Definition Language
    14) B. grant option
    15) D. domain
    16) C. functional dependency
    17) A. Parent-Child relationship between the tables that connect them
    18) A. mapping cardinality
    19) C. Data dictionary and transaction log
    20) D. super key

    Last edited by ajaytopgun; 6th February 2015 at 10:52 AM.

Tags for this Thread