CS506 – Enterprise Application Development: Midterm Important MCQs (304 Solved Questions)
Computer Science • Read every solved MCQ with its verified answer key directly on this page. Free, no login required.
All 664 Midterm Packs · CS506 Course Page · CS506 Subjective Pack (34 Q&As)
-
A class that is defined in another class is called
Topic: Java Basics & OOP
- Private class
- Public class
- Inner class ✓ Correct answer
- Derived class
-
A member variable or method prefixed by the protected access modifier can be accessed:
Topic: Java Basics & OOP
- Within the same class
- Within the sub-class
- Within the same package
- All of the above ✓ Correct answer
-
An abstract class --------------- instantiated.
Topic: Java Basics & OOP
- Cannot be ✓ Correct answer
- Can be
- Must
- None of these
-
Based on functionality, the streams can be categorized as
Topic: Java Basics & OOP
- Byte oriented stream and Node stream
- Filter stream and Character oriented stream
- Node stream and Filter stream ✓ Correct answer
- Byte oriented stream and Character oriented stream
-
DML stands for?
Topic: Java Basics & OOP
- Data Manipulation Language ✓ Correct answer
- Data Management Language
- Direct Manipulation Language
- Direct Management Language
-
HashMap takes key as a/an
Topic: Java Basics & OOP
- Object ✓ Correct answer
- Array
- Primitive value
- Function
-
Java developed in
Topic: Java Basics & OOP
- 1990
- 1995 ✓ Correct answer
- 1997
- 2000
-
Node stream fall into which category of streams?
Topic: Java Basics & OOP
- Character
- Byte ✓ Correct answer
- Integer
- Double
-
The relationship between class and interface is called
Topic: Java Basics & OOP
- ‘Is a' relationship
- ' Has a' relationship
- ' Responds to ' relationship ✓ Correct answer
- None of the given options
-
Which of the following is true about abstract class?
Topic: Java Basics & OOP
- An abstract class must have all methods declared as abstract methods
- Aclass must have at least one abstract method to be an abstract class
- A class without any abstract method can be declared as abstract class ✓ Correct answer
- An instance of abstract class can be created
-
Which one of the following blocks always executes irrespective of exception occurrence?
Topic: Java Basics & OOP
- Try block
- Catch block
- Throws block
- Finally block ✓ Correct answer
-
A final class can't be extended.
Topic: Java Basics & OOP
- True ✓ Correct answer
- False
-
A serializable class must implement the method(s)
Topic: Java Basics & OOP
- readObject and writeObject
- Either readObject or writeObject, or both, depending upon the desired behavior
- No need to implement any method ✓ Correct answer
- None of the given option
-
Aside from the Scanner class, which of the following classes can be used for text-file file input?
Topic: Java Basics & OOP
- ObjectInputStream
- Buffered Reader ✓ Correct answer
- StringTokenizer
- None of these
-
From the following; which approach is used in java to create threads,
Topic: Java Basics & OOP
- Interface
- Inheritance
- Both Interface and Inheritance ✓ Correct answer
- None of these
-
Java program’s code is compiled into a form called_ .
Topic: Java Basics & OOP
- Machine code
- Byte code ✓ Correct answer
- Native code
- Source code
-
The classes which contain the word _in their names are byte oriented streams.
Topic: Java Basics & OOP
- Reader
- Writer
- Stream ✓ Correct answer
- Byte
-
The collection API are defined in package.
Topic: Java Basics & OOP
- java.io
- java.util ✓ Correct answer
- java.awt
- java.sql
-
What if the main method is declared as private?
Topic: Java Basics & OOP
- The program does not compile
- The program compiles but does not run ✓ Correct answer
- The program compiles and runs properly
- The program throws an exception on compile time
-
Which of the following feature provides the facility for multiple inheritance?
Topic: Java Basics & OOP
- Adapter classes
- Wrapper classes
- Interfaces ✓ Correct answer
- Collections
-
Which of the following is modifier is provided by default if no access is written explicitly?
Topic: Java Basics & OOP
- public
- Private
- Protected
- Default ✓ Correct answer
-
Which of the following must be used to compare the values of two strings?
Topic: Java Basics & OOP
- = operator
- == operator
- equals() method ✓ Correct answer
- compare() method
-
== operator compares of strings whereas equals() method compares of strings.
Topic: Java Basics & OOP
- Values, addresses
- Addresses, values ✓ Correct answer
- Size, addresses
- Addresses, size
-
A _______________ defines the way and method of communication between two parties.
Topic: Java Basics & OOP
- Compiler
- Protocol ✓ Correct answer
- Tool
- Technique
-
A collection can store..........
Topic: Java Basics & OOP
- Homogenous objects
- Heterogeneous objects ✓ Correct answer
- Objects as well as primitive values
- At most 100 objects
-
A hash map object is to create, to store Teacher objects as values and their CNIC in the form of strings as keys.Which syntax is correct for this requirement?
Topic: Java Basics & OOP
- HashMap<String> h =new HashMap<String=();
- HashMap<String, Teacher> h =new HashMap<String, Teacher>(); ✓ Correct answer
- HashMap<Teacher> h =new HashMap<String, Teacher>();
- HashMap<Teacher> h =new HashMap<Teacher>();
-
A in HashMap is associated with each object that is stored.
Topic: Java Basics & OOP
- None of the given options
- Key ✓ Correct answer
- Value
- Attribute
-
A top level class may have only the following access modifier.
Topic: Java Basics & OOP
- Package
- Private
- Protected
- Public ✓ Correct answer
-
A top level class without any modifier is accessible to
Topic: Java Basics & OOP
- any class
- any class within the same package ✓ Correct answer
- any class within the same file
- any subclass of this class
-
A variable declared as static in a class is a/an
Topic: Java Basics & OOP
- Instance variable
- Class variable ✓ Correct answer
- Const variable
- Global variable
-
All java files in a directory are compiled using command in command prompt.
Topic: Java Basics & OOP
- javac *.java ✓ Correct answer
- javac all.java
- javac all
- java *.java
-
All the exceptions and errors in java are inherited from class.
Topic: Java Basics & OOP
- Exception
- Error
- Throwable ✓ Correct answer
- IOException
-
An exception in java is represented as a/an
Topic: Java Basics & OOP
- Operator
- Object ✓ Correct answer
- Function
- None
-
An instance of abstract class cannot be created.
Topic: Java Basics & OOP
- TRUE ✓ Correct answer
- FALSE
-
An object of Student java class is creating and setting its value in Test.java class. error is there in given code. public class Test{ public static void main (String args[]}{ Student s2 = new Student(); s2->setName(“Aslam”); }
Topic: Java Basics & OOP
- Class name is in wrong format
- s2 is not valid name of object of Student class
- setName method should not be accessed by arrow operator ✓ Correct answer
- no syntax error
-
Array List can store objects of _?
Topic: Java Basics & OOP
- Same types only
- Different types only
- Both same and different types ✓ Correct answer
- Can't store objects
-
ArrayList is an example of collection type.
Topic: Java Basics & OOP
- Sequence based ✓ Correct answer
- Set based
- Hashmap based
- None of the given
-
Assume that we do not want to serialize phoneNum attribute of Personinfo class, this can be done by;
Topic: Java Basics & OOP
- server String phoneNum;
- client String phoneNum;
- transient String phoneNum; ✓ Correct answer
- serializable String phoneNum:
-
By implementing this interface, a class declares that it is willing to be by automatic serialization machinery.
Topic: Java Basics & OOP
- Checked
- Decode
- Read ✓ Correct answer
- Destroyed
-
Bytecodes are created and stored on disk by .
Topic: Java Basics & OOP
- editor
- compiler ✓ Correct answer
- class loader
- bytecode verifier
-
Bytecodes are put in memory by _.
Topic: Java Basics & OOP
- Editor
- compiler
- class loader ✓ Correct answer
- bytecode verifier
-
Choose the correct syntax to declare an abstract java classnamed as "Person".
Topic: Java Basics & OOP
- abstract public class Person{}
- public class Person abstract{}
- public class abstract Person{}
- public abstract class Person{} ✓ Correct answer
-
CmdArgs java class is compiled. If the command “java CmdArgs CS506” run in cmd, then what will be output of given code. Public class CmdArgs{ public static void main(String[] args){ System.out.println(“First argument” + args[0]); }
Topic: Java Basics & OOP
- CS506 ✓ Correct answer
- Syntax error
- do not show any output
- args[0]
-
Consider the following code segment. ArrayList al = new ArrayList(); Person p = new Person() ; al.add(p); What will be the syntax to get an object from the first index of ArrayList?
Topic: Java Basics & OOP
- Person p = al.get(0) ;
- Person p = al.get(1) ;
- Person p = (Person)al.get(0) ; ✓ Correct answer
- Person p = (Person)al.get(1) ;
-
Converting a bigger data type into smaller data type is called _.
Topic: Java Basics & OOP
- Up-casting
- Down-casting ✓ Correct answer
- Normal-casting
- High-casting
-
DDL stands for?
Topic: Java Basics & OOP
- Data Definition Language ✓ Correct answer
- Data Driven Language
- Database Definition Language
- Database Driven Language
-
Exception handling code is written in _
Topic: Java Basics & OOP
- try block
- catch block ✓ Correct answer
- finally block
- throws clause
-
Exceptions must be handled while handling files otherwise it may lead to
Topic: Java Basics & OOP
- Logical error
- Syntax error
- Run-time error ✓ Correct answer
- No error
-
For each class contained in java source file, compiler generates class file/s.
Topic: Java Basics & OOP
- One ✓ Correct answer
- Two
- Three
- Four
-
From following classes; which one can’t be instantiated?
Topic: Java Basics & OOP
- Super class
- Abstract Class ✓ Correct answer
- Anonymous Class
- Concrete Class
-
From following; which is the main reason that enters a thread into dead state:
Topic: Java Basics & OOP
- It dies a natural death because thread completes its execution
- It is killed because someone invoked its stop method
- Both a and b.. ✓ Correct answer
- None of these
-
Given a one dimensional array arr, what is the correct way of getting the number of elements in arr
Topic: Java Basics & OOP
- arr.length ✓ Correct answer
- arr.length — 1
- arr.size — 1
- arr.lengthO
-
Given code is showing the result of addition of two integer type numbers. Choose correct output of this code. Int i = 7; int j = 8; int k = i+j; System.out.printIn(“Seven” + i + “plus Eight” + j + “is” + k);
Topic: Java Basics & OOP
- Seven 7 plus Eight 8 is 15 ✓ Correct answer
- Seven i plus Eight j is k
- Seven i plus Eight j is +15
- Seven plus Eight is k
-
How many methods are there in the Serializable Interface?
Topic: Java Basics & OOP
- Zero ✓ Correct answer
- One
- Two
- Three
-
INSERT, UPDATE, DELETE are statements.
Topic: Java Basics & OOP
- DDL
- DML ✓ Correct answer
- DCL
- None of given
-
If a class implements an interface then_
Topic: Java Basics & OOP
- an interface must provide implementation of all methods
- a class may or may not provide implementation of all methods of interface
- a class must provide implementation of all methods of interface ✓ Correct answer
- class will compile successfully if class do not implements methods of interface
-
If a super class method is protected then overriding method_
Topic: Java Basics & OOP
- must be protected
- must be public
- must be private
- may be either protected or public ✓ Correct answer
-
If the subclass overrides all the abstract methods of super class, then subclass is called _.
Topic: Java Basics & OOP
- Abstract class
- Concrete class ✓ Correct answer
- Base class
- Parent class
-
If there is a class "Student", then the java file must be saved with name.
Topic: Java Basics & OOP
- Student_File java
- student.java
- Any name
- Student.java ✓ Correct answer
-
If there is no exception in the try nor then the catch block executes.
Topic: Java Basics & OOP
- Always
- Sometime
- Never ✓ Correct answer
- None of the given
-
If we do not provide implementation of any one method of interface in a class that implements interface , class will:
Topic: Java Basics & OOP
- Provide default implementation
- Not compile
- Run having no error
- Become abstract ✓ Correct answer
-
If we remove String array from main then program
Topic: Java Basics & OOP
- Program cannot compile
- Program will compile and work properly
- Run time errors ✓ Correct answer
- Exception throws in main
-
If we remove static from main then program
Topic: Java Basics & OOP
- Program cannot compile
- Program will compile and work properly
- Run time errors ✓ Correct answer
- Exception throws in main
-
If we want to call toString() method of parent class in JAVA. Which of the following statement will be used?
Topic: Java Basics & OOP
- this. toString();
- new. toString();
- sub. toString();
- super.toString(); ✓ Correct answer
-
If you want the timer to fire only the first time and then stop, invoke .
Topic: Java Basics & OOP
- setRepeats(false) ✓ Correct answer
- setRepeats(true)
- setOnce(false)
- setOnce(true)
-
In Java an abstract class cannot be sub-classed
Topic: Java Basics & OOP
- True
- False ✓ Correct answer
-
In Java garbage collection is done by
Topic: Java Basics & OOP
- JVM (Java Virtual Machine) ✓ Correct answer
- Programmer
- Both JVM (Java Virtual Machine)and Programmer
- OS (Operating System) e. None of given
-
In Java, Serializable Interface can be found under package.
Topic: Java Basics & OOP
- java.io ✓ Correct answer
- java.net
- java.sql
- java.util
-
In Java, Transient fields are returned as null on reading.
Topic: Java Basics & OOP
- True ✓ Correct answer
- False
-
In editor java programs are created while stored on/in .
Topic: Java Basics & OOP
- Disk ✓ Correct answer
- primary memory
- external file
- usb
-
In given lines of code Employee is super class, Teacher is child class, is apply Employee e = new Teacher():
Topic: Java Basics & OOP
- upcasting Teacher to Employee type ✓ Correct answer
- upcasting Employee to Teacher type
- downcasting Teacher to Employee type
- downcasting Employee to Teacher type
-
In given lines of code, ______ is applying. double a = 9.5; int b = (int) a;
Topic: Java Basics & OOP
- upcasting a to b type
- upcasting b to a type
- downcasting a to b type ✓ Correct answer
- downcasting b to a type
-
In given lines of code, is applying. int a = 20: double b = a;
Topic: Java Basics & OOP
- upcasting a to b type ✓ Correct answer
- upcasting b to a type
- downcasting a to b type
- downcasting b to a type
-
In multi tier architecture object transfer can only happen if one of the following statements about objects is correct?
Topic: Java Basics & OOP
- Objects should be always present.
- Objects reference should be set.
- Objects should be abstract.
- Objects need to be serialized. ✓ Correct answer
-
In polymorphism, ______ are overridden.
Topic: Java Basics & OOP
- Variables
- Methods ✓ Correct answer
- Data types
- Classes
-
IndexOutOfBoundsExceptoin occurs when:
Topic: Java Basics & OOP
- File is not present.
- Incorrect data type conversion is forced to do.
- Command line arguments are not passed. ✓ Correct answer
- Number is divided by zero.
-
Interface imposes structure on any class that uses interface
Topic: Java Basics & OOP
- code
- design ✓ Correct answer
- implementation
- inheritance
-
It is verified by that not all bytecodes violate java security restrictions.
Topic: Java Basics & OOP
- Editor
- Compiler
- class loader
- bytecode verifier ✓ Correct answer
-
Java compiler handles __________ exceptions by default.
Topic: Java Basics & OOP
- Checked
- Unchecked
- Both checked and unchecked ✓ Correct answer
- None of the given
-
Java core language is than C++.
Topic: Java Basics & OOP
- Simpler ✓ Correct answer
- Difficult
- Complex
- Less secure
-
Java does not handle exception by as keyword.
Topic: Java Basics & OOP
- try
- catch
- exception ✓ Correct answer
- finally
-
Java is a _ language.
Topic: Java Basics & OOP
- Complicated
- Not portable
- Static
- Multi threaded ✓ Correct answer
-
Java language has a little worse performance than C++ language, because
Topic: Java Basics & OOP
- it is object oriented
- it uses built in libraries ✓ Correct answer
- it does not use pointers
- it checks all errors, malicious and viruses
-
Java provide
Topic: Java Basics & OOP
- Overloading
- Overriding ✓ Correct answer
- Pointers
- Multiple Inheritance
-
Objects are always written /read in which of the following form.
Topic: Java Basics & OOP
- method
- variables
- class
- binary ✓ Correct answer
-
Overloading is _whereas overriding is
Topic: Java Basics & OOP
- Run time binding, compile time binding
- Late binding, compile time binding
- Compile time binding, run time binding ✓ Correct answer
- Run time binding, late time binding
-
Static methods can only access
Topic: Java Basics & OOP
- Instance variables
- Instance methods
- Static variables and methods ✓ Correct answer
- Both static and instance members
-
Strings in java are represented as
Topic: Java Basics & OOP
- Primitive data types
- Reference data types ✓ Correct answer
- Native data types
- Operators
-
Suppose strings are stored in a collection “arraylist”. Get one string element and store in element variable. Choose correct line of code for this requirement.
Topic: Java Basics & OOP
- String element = String arraylist.get(i);
- String element = (String)arraylist.get(i); ✓ Correct answer
- String element = element arraylist.get(i);
- String element = (element) arraylist.get(i);
-
Teacher java class wants to inherit from Employee.java class, keyword should public static void main (String args[]){ }}
Topic: Java Basics & OOP
- inherit
- implement
- extends ✓ Correct answer
- override
-
The following is an example of . BufferedReaderbr = new BufferedReader(fr);
Topic: Java Basics & OOP
- Byte oriented stream
- Node stream
- Filter stream ✓ Correct answer
- File stream
-
The following is an example of _. FileReaderfr = new FileReader(“input txt”);
Topic: Java Basics & OOP
- Byte oriented stream
- Node stream ✓ Correct answer
- Filter stream
- File stream
-
The given line of code will result in System.out.println(5+9);
Topic: Java Basics & OOP
- 59
- 5+9
- 14 ✓ Correct answer
- Syntax error
-
The is directly connected with keyboard.
Topic: Java Basics & OOP
- File stream
- Character oriented stream
- Node stream ✓ Correct answer
- Filter stream
-
The keyword "this" is used to
Topic: Java Basics & OOP
- invoke constructor of the another class
- invoke alternate constructor of the same class ✓ Correct answer
- invoke constructor of super class from sub class
- invoke constructor of sub class from super class
-
The method "Math.random()" returns positive double value greater than or equal to 1 or less than 10.
Topic: Java Basics & OOP
- True
- False ✓ Correct answer
-
The output of given someTest function is _. public void someTest( ) { int x; System.out.printIn(x); }
Topic: Java Basics & OOP
- x
- syntax error
- compile time error ✓ Correct answer
- run time error
-
The toString() method returns a representation of .
Topic: Java Basics & OOP
- int,string
- string,int
- string,object ✓ Correct answer
- object,string
-
There are types of exceptions in Java
Topic: Java Basics & OOP
- 2 ✓ Correct answer
- 3
- 4
- 5
-
Timer class constructor requires time in _.
Topic: Java Basics & OOP
- seconds
- milli seconds ✓ Correct answer
- micro seconds
- nano seconds
-
To compile "Test.java" class, command is used in java.
Topic: Java Basics & OOP
- javac Test.java ✓ Correct answer
- javac Test
- java Test.java
- java Test
-
To make sure array accesses touch only the memory allocated to them, JVM does checking at runtime.
Topic: Java Basics & OOP
- dynamic ✓ Correct answer
- static
- consistent
- not
-
What will be the output of following statement? System.out.println(29+5);
Topic: Java Basics & OOP
- 34 ✓ Correct answer
- 29+5
- 295
- None of the given options
-
What will happen if static modifier is removed from the signature of main method?
Topic: Java Basics & OOP
- The program does not compile
- The program compiles and runs successfully
- The program compiles but does not run ✓ Correct answer
- None of given options
-
When there is just a onetime use of a particular object of a java class, we use _.
Topic: Java Basics & OOP
- named object
- anonymous object ✓ Correct answer
- either named object or anonymous object
- either named object nor anonymous object
-
Which command of the following commands is used to compile “JavaTest” java file’s code?
Topic: Java Basics & OOP
- java JavaTest
- javac JavaTest.java ✓ Correct answer
- javacJavaTest
- java JavaTest.java
-
Which feature of the following features does Java provide?
Topic: Java Basics & OOP
- Operator Overloading
- Pointers
- Function Overriding ✓ Correct answer
- Multiple Inheritance
-
Which feature of the following features is not included in Java language?
Topic: Java Basics & OOP
- Inheritance
- Polymorphism
- Pointer manipulation ✓ Correct answer
- Data encapsulation
-
Which of the following belongs to a category of checked exception?
Topic: Java Basics & OOP
- Null Pointer exception
- IOException ✓ Correct answer
- Array index out of bounds
- NumberFormatException
-
Which of the following classes is capable to instantiate?
Topic: Java Basics & OOP
- Abstract class
- Concrete class ✓ Correct answer
- Interface class
- None of the given
-
Which of the following command is used to compile Java code?
Topic: Java Basics & OOP
- java filename
- javac filename.java ✓ Correct answer
- javac filename
- java filename.java
-
Which of the following exception belongs to a category of un-checked exception?
Topic: Java Basics & OOP
- IOException
- Null Pointer exception ✓ Correct answer
- AWT Exception
- ClassNotFoundException
-
Which of the following features is available in java?
Topic: Java Basics & OOP
- Pointers
- Operator overloading
- Global variables
- Primitive data types ✓ Correct answer
-
Which of the following features is not available in Java?
Topic: Java Basics & OOP
- Data hiding
- Data encapsulation
- Single inheritance
- Multiple inheritance ✓ Correct answer
-
Which of the following interface needs to implement while creating threads?
Topic: Java Basics & OOP
- Serializable
- Runnable ✓ Correct answer
- ActionListener
- WindowListener
-
Which of the following is NOT true for java inner classes?
Topic: Java Basics & OOP
- Can have constructors
- Can have instance variables
- Can have Methods
- Generally used as public utility classes ✓ Correct answer
-
Which of the following is a DDL statement?
Topic: Java Basics & OOP
- Select
- Delete
- Create ✓ Correct answer
- Update
-
Which of the following is a type of Java web application technologies?
Topic: Java Basics & OOP
- JSTL
- JSF
- JSP
- All of the given ✓ Correct answer
-
Which of the following is a valid variable name in Java?
Topic: Java Basics & OOP
- 1xu
- Vu.506
- NumberOfStudent ✓ Correct answer
- Long
-
Which of the following is called “pure abstract class”?
Topic: Java Basics & OOP
- Concrete class
- Wrapper class
- Interface ✓ Correct answer
- Abstract class with no abstract method
-
Which of the following is correct java code statement that is used to establish the connection?
Topic: Java Basics & OOP
- Connection con = DriverManager.getConnection(conURL) ✓ Correct answer
- connection Con = driverManager.getConnection(conURL)
- connection Con = driverManager.getConnection(conURL)
- Connection con = driverManager.getConnection(conURL)
-
Which of the following is not true about constructor?
Topic: Java Basics & OOP
- Same name as class name
- Does not have any parameter(s) ✓ Correct answer
- No initialization list
- Does not have return type
-
Which of the following is the correct syntax to make a PersonInfo class into a Serializable class?
Topic: Java Basics & OOP
- Public class PersonInfo includes Serializabte { /* class body */}
- Public class PersonInfo imports Serializabte { /* class body */}
- Public class PersonInfo extends Serializabte { /* class body */}
- Public class PersonInfo implements Serializabte { /* class body */} ✓ Correct answer
-
Which of the following is the correct way to access writeObject() function using “out” object of ObjectOutputStream class.
Topic: Java Basics & OOP
- out->writeObject()
- out<-writeObject()
- out->(.writObject())
- out.writObject() ✓ Correct answer
-
Which of the following is used for inheritance in java?
Topic: Java Basics & OOP
- implements
- extends ✓ Correct answer
- : (colon)
- inherit
-
Which of the following method allows any other thread of same priority to execute?
Topic: Java Basics & OOP
- sleep()
- wait()
- notify()
- yield() ✓ Correct answer
-
Which of the following method is used to convert a string into an int value?
Topic: Java Basics & OOP
- intValue(}
- parselnt() ✓ Correct answer
- Parselnt()
- parselnteger()
-
Which of the following method needs to override while handling threads in java?
Topic: Java Basics & OOP
- init()
- start()
- run() ✓ Correct answer
- runnable()
-
Which of the following name is used by the system to recognize the underlying data source?
Topic: Java Basics & OOP
- DNS
- DSN ✓ Correct answer
- JDBC
- ODBC
-
Which of the following operator is used to concatenate strings?
Topic: Java Basics & OOP
- +=
- +-
- ++
- + ✓ Correct answer
-
Which of the following problem occurs with lower priority threads?
Topic: Java Basics & OOP
- Race condition
- Starvation ✓ Correct answer
- Average waiting time
- Process death
-
Which of the following range of response code indicates that request was successful?
Topic: Java Basics & OOP
- 100-199
- 200-299 ✓ Correct answer
- 300-399
- 400-499
-
Which of the following statement regarding Java is false?
Topic: Java Basics & OOP
- Java is a programming language
- A Java program compiles into machine language ✓ Correct answer
- Java is case sensitive language
- Java uses an interpreter
-
Which of the following statements attaches an output stream to console?
Topic: Java Basics & OOP
- FileWriter fw = new FileWriter(“output.txt”);
- FileWriter fw = new FileWriter(FileDescriptor.out); ✓ Correct answer
- FileWriter fw = new FileWriter(FileDescriptor.in);
- FileWriter fw = new FileWriter(FileDescriptor);
-
Which of the following statements is true about primitive data types and reference data types?
Topic: Java Basics & OOP
- Primitive data types are created on heap whereas references are created on stack
- Both primitive data type and references are created on stack
- Primitive data types are created on stack whereas references are created on heap ✓ Correct answer
- Both primitive data types and references are created on heap
-
Which of the following statements is true regarding Vectors with no specified base type?
Topic: Java Basics & OOP
- A base type is needed, because Java needs to know how to allocate memory
- No base type is needed, because Java will use the Object class as a base type ✓ Correct answer
- If a base type is not specified the code will not compile
- No base type is needed because Vectors default to storing String objects
-
Which of the following stream is a Node stream?
Topic: Java Basics & OOP
- PrintWriter
- FileWriter ✓ Correct answer
- BufferedReader
- All of given option
-
Which of the following stream is a filter stream?
Topic: Java Basics & OOP
- FileWriter
- FileReader `
- BufferedReader ✓ Correct answer
- All of given options
-
Which of the following stream read/write data in the form of bytes?
Topic: Java Basics & OOP
- FileReader
- FileWriter
- PrintWriter
- FileInputStream ✓ Correct answer
-
Which of the following streams is a byte oriented stream?
Topic: Java Basics & OOP
- FileReader
- PrintWriter
- BufferedReader
- FileInputStream ✓ Correct answer
-
Which of the following syntax is used to attach an input stream to console?
Topic: Java Basics & OOP
- FileReaderfr = new FileReader(' input.txt ') ;
- FileReaderfr = new FileReader(FileDescriptor.in); ✓ Correct answer
- FileReaderfr = new FileReader(FileDescriptor);
- FileReaderfr = new FileReader(console);
-
Which of the following understands the byte code?
Topic: Java Basics & OOP
- Operating system
- Java compiler
- Java Virtual Machine ✓ Correct answer
- Java Interpreter
-
Which of these are valid declarations for the main method?
Topic: Java Basics & OOP
- public void main();
- public static void main(String args[]); ✓ Correct answer
- static public void main(String);
- public static int main(String args|]);
-
Which package contains ArrayList?
Topic: Java Basics & OOP
- java.awt
- java.util ✓ Correct answer
- javax.swing
- java.lang
-
Which statement from the following statements is true about a java Anonymous Inner Class
Topic: Java Basics & OOP
- It is difficult to understand
- It has no name
- It is much shorter
- All of the given options ✓ Correct answer
-
While running following ExceptionExample.java class on command line without passing command line arguments gives_ exception. public class ExceptionExample { public static void main (String args[]) { System.out.println(args[0]); }}
Topic: Java Basics & OOP
- Null pointer exception
- Array index out of bound exception ✓ Correct answer
- Divide by zero exception
- IO Exception
-
You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?
Topic: Java Basics & OOP
- public
- private
- protected
- transient
- default access ✓ Correct answer
-
_is/are not part of java core language.
Topic: Java Basics & OOP
- ArrayList class ✓ Correct answer
- Variables
- Arrays
- Objects
-
in a collection class creates a collection with no elements.
Topic: Java Basics & OOP
- Constructors ✓ Correct answer
- Class
- Function
- Array
-
int i = (int)( Math.random() * 5 ); // will generate random numbers between _____.
Topic: Java Basics & OOP
- 0 ✓ Correct answer
- 0
- 1
- 1
-
int x = 7/2; value of x is:
Topic: Java Basics & OOP
- 1
- 2
- 3.5
- 3 ✓ Correct answer
-
is required in order to get an object from collection.
Topic: Java Basics & OOP
- Up-casting
- Down casting ✓ Correct answer
- Implicit casting
- None of the given options
-
isReadOnly() is a method of _ object.
Topic: Java Basics & OOP
- ResultSet
- ResultSetMetaData ✓ Correct answer
- DataBaseMetaData
- Connection
-
previous() is a method of object
Topic: Java Basics & OOP
- Statement
- ResultSet ✓ Correct answer
- ResultSetMetaData
- Connection
-
returns the elements at specified position in the list.
Topic: Java Basics & OOP
- Object get(int index) ✓ Correct answer
- Object set(int index)
- Object return(int index)
- Object remove(int index)
-
Window frame and dialog use as their default layout.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Border layout ✓ Correct answer
- Flow layout
- GridBag layout
- Grid layout
-
Event handling is step process.
Topic: GUI, AWT/Swing, Applets & Event Handling
- 1
- 2
- 3 ✓ Correct answer
- 4
-
If a JPanel has a triangle drawn on it which of the following method will display it
Topic: GUI, AWT/Swing, Applets & Event Handling
- PaintBorder()
- Paint()
- paintChildren()
- paintComponent() ✓ Correct answer
-
Java defines for the listener interfaces having more than one event handling methods.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Wrapper Classes
- Abstract Classes
- Concrete Classes
- Adapter Classes ✓ Correct answer
-
Which of the given Listener Interfaces is need to handle the “KeyEvent"?
Topic: GUI, AWT/Swing, Applets & Event Handling
- MouseKeyListener
- MotionKeyListener
- KeyListener ✓ Correct answer
- KeyActionListener
-
Which of the following function will be used to register event handler with events generator, where event generator is button?
Topic: GUI, AWT/Swing, Applets & Event Handling
- AddAction()
- addActionListener() ✓ Correct answer
- addListener()
- registerListener
-
Which of the following functions is declared in MouseMotionListener interface?
Topic: GUI, AWT/Swing, Applets & Event Handling
- public void mousePressed (MouseEvent me);
- public void mouseDragged(MouseEvent me); ✓ Correct answer
- public void mouseClicked (MouseEvent me);
- public void mouseEntered (MouseEvent me);
-
AWT is a GUI package used in java, AWT stands for .
Topic: GUI, AWT/Swing, Applets & Event Handling
- Apache Windows Toolkit
- Application Windowing Tools
- Application Windows Template
- Abstract Windowing Toolkit ✓ Correct answer
-
AWT is also called _.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Heavy weight components ✓ Correct answer
- Light weight components
- Both Light weight and heavy weight components
- Neither Light weight nor heavy weight
-
Adapter classes have been defined for listener interfaces except interface.
Topic: GUI, AWT/Swing, Applets & Event Handling
- MouseListener
- KeyListener
- WindowlListener
- ActionListener ✓ Correct answer
-
All AWT and swing components generate events.
Topic: GUI, AWT/Swing, Applets & Event Handling
- True ✓ Correct answer
- False
-
An applet can be defined as:
Topic: GUI, AWT/Swing, Applets & Event Handling
- A small program written in Java and included in an HTML page ✓ Correct answer
- A small program written in JSP and included in an HTML page
- A small program written in Servlet and included in an HTML page
- A small program written in JSF and included in an HTML . Choose the correct syntax to define an interface named as "Speaker" in java language
-
An applet is a JFrame that allows interaction with a Java program.
Topic: GUI, AWT/Swing, Applets & Event Handling
- True
- False ✓ Correct answer
-
An event in java is represented as
Topic: GUI, AWT/Swing, Applets & Event Handling
- Operator
- Function
- Object ✓ Correct answer
- Primitive data type
-
Border Layout is the default layout manager for a JFrame’s content pane
Topic: GUI, AWT/Swing, Applets & Event Handling
- True ✓ Correct answer
- False
-
Border layout divides the area into regions
Topic: GUI, AWT/Swing, Applets & Event Handling
- 3
- 4
- 5 ✓ Correct answer
- Pm 6
-
Event source can have --------- listeners registered on it.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Single
- Double
- Triple
- Multiple ✓ Correct answer
-
Following are the code statements used in java event handling. Identify the code statement that is used for registering event handler with event generator
Topic: GUI, AWT/Swing, Applets & Event Handling
- b1 = new JButton("OK")
- b1.addActiobListener(this) ✓ Correct answer
- frame = new JFrame()
- frame.setSize(150,
-
For a programmer the event handling is a three step process in terms of code. Which of the following is NOT an event handling step?
Topic: GUI, AWT/Swing, Applets & Event Handling
- Generate event
- Handle event
- Publish event ✓ Correct answer
- Register handler with generator
-
If a class needs to handle events generated by button then which of the following interface a classneeds to implement?
Topic: GUI, AWT/Swing, Applets & Event Handling
- ComponentListener
- KeyListener
- MouseListener
- Action Listener ✓ Correct answer
-
If we want to animate something like ball, moving from one place to another. we constantly need to call paint () method.
Topic: GUI, AWT/Swing, Applets & Event Handling
- True
- False ✓ Correct answer
-
If we want to handle mouse Clicked, released or pressed, Which of the following interface do we need to implement?
Topic: GUI, AWT/Swing, Applets & Event Handling
- MouseMoved
- MouseDragged
- MouseMotionListener
- MouseListener ✓ Correct answer
-
In Java Graphics, while painting a swing component. which of the following functions is invoked first?
Topic: GUI, AWT/Swing, Applets & Event Handling
- Paint()
- paintComponent() ✓ Correct answer
- paintBorder()
- PaintChildern()
-
In Java, which of these classes implement the LayoutManager interface?
Topic: GUI, AWT/Swing, Applets & Event Handling
- RowLayout
- ColumnLayout
- GridBagLayout ✓ Correct answer
- Flow LayoutManager
-
In an applet class definition, the method takes the place of the constructor.
Topic: GUI, AWT/Swing, Applets & Event Handling
- paint();
- main();
- init(); ✓ Correct answer
- run();
-
In given lines of code is static variable and is static method. System.out.printin(“CS506”); JOptionPane.showMessageDialog(null,“CS506”)
Topic: GUI, AWT/Swing, Applets & Event Handling
- System, JOptionPane
- PrintIn, showMessageDialog
- PrintIn, JOptionPane
- Out, showMessageDialog ✓ Correct answer
-
In java, adapter classes have been defined for the following listener interfaces except interface
Topic: GUI, AWT/Swing, Applets & Event Handling
- FocusListener
- ComponentListener
- MouseMotionListener
- ItemListener ✓ Correct answer
-
In order to include graphics in your Java program, it is mandatory to extend from class.
Topic: GUI, AWT/Swing, Applets & Event Handling
- JLabel
- JFrame
- JPanel ✓ Correct answer
- JButton
-
In the context of Java Graphics, paintChildren( ) method tells any component contained by this component to paint itself.(themselves).
Topic: GUI, AWT/Swing, Applets & Event Handling
- True ✓ Correct answer
- False
-
In the context of Java Graphics, which of the following methods we should override while painting?
Topic: GUI, AWT/Swing, Applets & Event Handling
- paint() ✓ Correct answer
- paintComponet( )
- paintBorder( )
- paintChildern( )
-
In the context of Java Graphics; most of time, painting is done automatically.
Topic: GUI, AWT/Swing, Applets & Event Handling
- True ✓ Correct answer
- False
-
JPanel and Applet use as their default layout.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Flow layout ✓ Correct answer
- Border layout
- Grid layout
- GridBag layout
-
JVM put the events generated by event generator in a _______.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Stack
- Queue ✓ Correct answer
- List
- Hash table
-
Java compiler is called on UNIX or windows.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Javac ✓ Correct answer
- java c
- cjava
- c java
-
Mouse events can be trapped for GUI component.
Topic: GUI, AWT/Swing, Applets & Event Handling
- JPanel
- JFrame
- JButton
- Allofgiven ✓ Correct answer
-
Mouse motion event is generated when mouse is:
Topic: GUI, AWT/Swing, Applets & Event Handling
- Pressed
- Entered
- Clicked
- Dragged ✓ Correct answer
-
Painting is managed by the system, so calling paintComponent() directly is NOT recommended at all,
Topic: GUI, AWT/Swing, Applets & Event Handling
- True ✓ Correct answer
- False
-
Suppose we have to create a GUI with the following design: Stretches horizontally and has a fixed height; Stretches vertically and has a fixed Width; Takes up as much space as possible in all directions. What is the best single Layout to use?
Topic: GUI, AWT/Swing, Applets & Event Handling
- Border Layout
- Grid Layout
- Flow Layout
- Box Layout ✓ Correct answer
-
The class that handles mouse event needs to implement the corresponding interface and to provide the definition of:
Topic: GUI, AWT/Swing, Applets & Event Handling
- One method in that interface
- Two methods in that interface
- All the methods in that interface ✓ Correct answer
- Do not need to provide definition of methods in that interface
-
The code below draws a line. What color is the line? g.setColor(Color.red. green. yellow.red); g.drawLine(0, 0, 100,100);
Topic: GUI, AWT/Swing, Applets & Event Handling
- Red
- Green
- Yellow
- Black ✓ Correct answer
-
The following code creates and starts a timer that fires an action event once per_ Timer t = new Timer (1000, this); t.start();
Topic: GUI, AWT/Swing, Applets & Event Handling
- Second ✓ Correct answer
- Minute
- Hour
- Day
-
The “MouseDragged” and “mouseMoved" methods are defined in interface.
Topic: GUI, AWT/Swing, Applets & Event Handling
- MouseListener
- ltemListener
- MouseMotionListener ✓ Correct answer
- ActionListener
-
Timers are constructed by specifying both a delay parameter and a/an Listener.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Action ✓ Correct answer
- Mouse
- Key
- Window
-
What does the following code draw? g.setColor(Color.black); g.drawLine(10, 10, 10, 50); g.setColor(Color.RED); g.drawRect(100, 100, 150, 150);
Topic: GUI, AWT/Swing, Applets & Event Handling
- A red vertical line that is 40 pixels long and a red square with sides of 150 pixels
- A black vertical line that is 40 pixels long and a red square with sides of 150 pixels ✓ Correct answer
- A black vertical line that is 50 pixels long and a red square with sides of 150 pixels
- A red vertical line that is 50 pixels long and a red square with sides of 150 pixels
-
When you maximizes the applet which was minimized a few time before which of the following method will be called?
Topic: GUI, AWT/Swing, Applets & Event Handling
- start() ✓ Correct answer
- stop()
- init()
- destroy()
-
Which of the following Statements is true regarding paintChildren() method?
Topic: GUI, AWT/Swing, Applets & Event Handling
- It tells the component to paint its border
- It first paints the background and then performs custom painting
- If first performs custom painting and then paints the background
- It tells any components contained by this component to paint themselves ✓ Correct answer
-
Which of the following are passed as an argument to the paint ( ) method?
Topic: GUI, AWT/Swing, Applets & Event Handling
- A Canvas object
- A Graphics object ✓ Correct answer
- An Image object
- A paint object
-
Which of the following classes provide definitions for all the methods (empty bodies) of their corresponding Listener interface?
Topic: GUI, AWT/Swing, Applets & Event Handling
- private classes
- public classes
- adapter classes ✓ Correct answer
- inner classes
-
Which of the following command is used to invoke an Applet from command line interpreter?
Topic: GUI, AWT/Swing, Applets & Event Handling
- Applet htmlfile
- appletviewer htmlfile ✓ Correct answer
- appletviewer javafile
- viewer htmlfile
-
Which of the following is NOT true about paintComponent( ) method?
Topic: GUI, AWT/Swing, Applets & Event Handling
- It is a main method for painting
- By default, it first paints the background
- Tells the components border (if any) to paint ✓ Correct answer
- It performs custom painting (drawing circle, rectangles etc.)
-
Which of the following is NOT true for an Applet?
Topic: GUI, AWT/Swing, Applets & Event Handling
- A small program written in Java and included in a HTML page
- It is independent of the operating system on which it runs
- They have no access to the client’s file system. ) and ✓ Correct answer
- An applet is a Panel that allows interaction with a Java program
-
Which of the following is a correct registration method for Focus Listener interface?
Topic: GUI, AWT/Swing, Applets & Event Handling
- addFocusListener ✓ Correct answer
- addFocusedListener
- regFocusListener
- regFocusedListener
-
Which of the following is a correct statement for “mouse click” event in “MouseListener’” interface?
Topic: GUI, AWT/Swing, Applets & Event Handling
- public void mouseclicked (MouseEvent me)
- public void MouseClicked (MouseEvent me)
- public void mouseClicked (MouseEvent me) ✓ Correct answer
- public void Mouseclicked (MouseEvent me)
-
Which of the following is a general purpose container?
Topic: GUI, AWT/Swing, Applets & Event Handling
- JFrame
- Dialog
- JPanel ✓ Correct answer
- JApplet
-
Which of the following is a top level container?
Topic: GUI, AWT/Swing, Applets & Event Handling
- JPanel
- ToolBar
- ScrollPane
- Dialog ✓ Correct answer
-
Which of the following is true about AWT and SWING components?
Topic: GUI, AWT/Swing, Applets & Event Handling
- AWT components create a process whereas SWING component creates a thread ✓ Correct answer
- AWT components create a thread whereas SWING component creates a process
- Both AWT and SWING component creates a process
- Both AWT and SWING component creates a thread
-
Which of the following method of Graphics object is used to draw rectangle?
Topic: GUI, AWT/Swing, Applets & Event Handling
- DrawRect(10,10,20,20);
- drawRect(10,10,20,20); ✓ Correct answer
- drawReactangle(10,10,20,20);
- DrawReactangle(10,10,20,20);
-
Which of the following method of an Applet is called every time when page is minimized?
Topic: GUI, AWT/Swing, Applets & Event Handling
- start()
- init()
- stop() ✓ Correct answer
- destroy()
-
Which of the following methods is called only once during the life cycle of an Applet?
Topic: GUI, AWT/Swing, Applets & Event Handling
- start( )
- paint()
- stop()
- destroy() ✓ Correct answer
-
Which of the following methods takes the place of constructor in an Applet?
Topic: GUI, AWT/Swing, Applets & Event Handling
- Run()
- Main()
- Init() ✓ Correct answer
- Start()
-
Which of the following object is passed as an argument to paintComponent() method?
Topic: GUI, AWT/Swing, Applets & Event Handling
- Image object
- Jpanel object
- JFrame object
- Graphic object ✓ Correct answer
-
Which of the following statement is true regarding paintComponent() method?
Topic: GUI, AWT/Swing, Applets & Event Handling
- It tells any components contained by this component to paint themselves
- It tells the component to paint its border
- It first paints the background and then performs custom painting ✓ Correct answer
- It first performs custom painting and then paints the background
-
Which of the following statements is a correct statement for “mouse release” event in “MouseListener” interface?
Topic: GUI, AWT/Swing, Applets & Event Handling
- public void mouseRelease(MouseEvent me)
- Public void mouseRelease(MouseEvent me
- public void mouseReleased(MouseEvent me) ✓ Correct answer
- Public void mouseReleased(MouseEvent me)
-
Which of the given Listener Interface is need to handle the “ActionEvent'?
Topic: GUI, AWT/Swing, Applets & Event Handling
- MouseActionListener
- KeyAction Listener
- ActionListener ✓ Correct answer
- MotionListener
-
Which of the given Listener Interfaces is needed to handle the “MouseEvent”?
Topic: GUI, AWT/Swing, Applets & Event Handling
- MouseListener ✓ Correct answer
- MouseMotionListener
- MouseActionListener
- MouseFocusListener
-
Which of the given Listener interface(s) have adopter class(s)?
Topic: GUI, AWT/Swing, Applets & Event Handling
- ActionListener
- MouseMotionListener ✓ Correct answer
- AdjustmentListener
- ltemListener
-
Which of the given methods is/are declared for“MouseListener” interface?
Topic: GUI, AWT/Swing, Applets & Event Handling
- MouseMoved
- MouseDragged
- MousePressed ✓ Correct answer
- MouseKeyPressed
-
Which of the given will clear all the previous painting?
Topic: GUI, AWT/Swing, Applets & Event Handling
- super.paintComponent() ✓ Correct answer
- super paint()
- super. repaint()
- super.redraw()
-
Which one of the following is not a method of MouseListener interface?
Topic: GUI, AWT/Swing, Applets & Event Handling
- Pressed
- Clicked
- Moved ✓ Correct answer
- Released
-
Window Adaptor class implements Window Listener interface and provide the definition of all method inside..........
Topic: GUI, AWT/Swing, Applets & Event Handling
- WindowListener interface ✓ Correct answer
- Inner Class
- Outer class
- Window adaptor class
-
Window Listener interface contains methods.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Four
- Six
- Seven ✓ Correct answer
- Eight
-
WindowListener interface contains methods.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Four
- Six
- Seven ✓ Correct answer
- Eight
-
is correct syntax to create a general purpose container “myPanel” having flow layout.
Topic: GUI, AWT/Swing, Applets & Event Handling
- JPanel myPanel = new JPanel (FlowLayout()};
- JPanel myPanel = new JPanel (new FlowLayout};
- JPanel myPanel = new JPanel (new FlowLayout()}; ✓ Correct answer
- JPanel myPanel = JPanel (FlowLayout()};
-
is correct syntax to get component area of“myFrame” top level container.
Topic: GUI, AWT/Swing, Applets & Event Handling
- Container c = myFrame.getComponentPane();
- Container c = myFrame.getContentArea();
- Container c = myFrame.getContentPane(); ✓ Correct answer
- Container c = myFrame->getComponentArea();
-
setColor() is a method of _ object.
Topic: GUI, AWT/Swing, Applets & Event Handling
- JPanel
- JFrame
- Graphics ✓ Correct answer
- Image
-
Which of the following statement object is used to execute precompiled SQL statements?
Topic: JDBC & Databases
- Statement
- PreparedStatement ✓ Correct answer
- CallableStatement
- None of give Option
-
Which driver is the network type driver from the following?
Topic: JDBC & Databases
- Type 1
- Type 2
- Type 3 ✓ Correct answer
- Type 4
-
Which of the following is NOT a method of ResultSet object?
Topic: JDBC & Databases
- next()
- absolute(int)
- executeQuery(sql) ✓ Correct answer
- updateRow()
-
Which of the following method is used to execute INSERT, UPDATE and Delete SQL statements?
Topic: JDBC & Databases
- ExecuteQuery(sql);
- ExecuteQuery(sql);
- Execute Update(sql); ✓ Correct answer
- Execute Update(sql);
-
Which of the following statement is TRUE regarding default ResultSet?
Topic: JDBC & Databases
- The default ResultSet is updatable and moves only forward.
- The default ResultSet is not updatable and moves only forward. ✓ Correct answer
- The default ResultSet is not updatable and moves forward as well as backward.
- The default ResultSet is updatable and moves forward as well as backward.
-
Which of the following statement object is used to execute simple SQL statement?
Topic: JDBC & Databases
- Statement ✓ Correct answer
- PreparedStatement
- CallableStatement
- None of given
-
Which of the following statement object is used to execute stored procedures?
Topic: JDBC & Databases
- Statement
- PreparedStatement
- CallableStatement ✓ Correct answer
- None of given options
-
Which of the following syntax is used to get ResultSetMetaData object?
Topic: JDBC & Databases
- ResultSetMetaData md = con.getMetaData(); // where con is Connection object
- ResultSetMetaData md = rs.getMetaData() // where rs is ResultSet object ✓ Correct answer
- ResultSetMetaData md = st.getMetaDataQ); // where st is Statement object
- ResultSet md = rs.getMetaData(); // where rs is ResultSetMetaDta object
-
You must include a to declare an exception that might be thrown to another method.
Topic: JDBC & Databases
- try block
- finally block
- catch block
- throws-clause ✓ Correct answer
-
To create DataBaseMetaData object we write following line of code
Topic: JDBC & Databases
- DatabaseMetaData db = con.getMeataData(); ✓ Correct answer
- ResultSetMetaDatarsmd = rs.getMetaData();
- ResultSetMetaDatarsmd = rs.setMetaDataQ);
- DataBaseMetaData db = con.setMeataData();
-
A database that is created in MS Access 2003 will be saved with extension.
Topic: JDBC & Databases
- java
- class
- doc
- mdb ✓ Correct answer
-
A default ResultSet object has a cursor that .
Topic: JDBC & Databases
- moves backward only
- moves forward only ✓ Correct answer
- moves backward and Forward
- cannot move
-
A scrollable and updatable ResultSet object has the following capabilities except
Topic: JDBC & Databases
- insert new rows
- insert new columns ✓ Correct answer
- delete rows
- update rows
-
An applet is typically embedded in a Web page and can be run from a browser.
Topic: JDBC & Databases
- True ✓ Correct answer
- False
-
CREATE, ALTER, DROP are _ SQL statements.
Topic: JDBC & Databases
- DML
- DDL ✓ Correct answer
- DCL
- None of given
-
Consider the following code segment. String sql = SELECT * FROM Table ; PreparedStatement pstmt = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); Which of the following option is true?
Topic: JDBC & Databases
- It creates Updatable/Scrollable ResultSet which moves forward only.
- It creates Updatable/Scrollable ResultSet which moves backward only
- It creates Updatable/Scrollable ResultSet which moves forward as well as backward. ✓ Correct answer
- It creates default ResultSet which moves forward as well as backward.
-
DSN stands for
Topic: JDBC & Databases
- Data System Name
- Domain system Name
- Data Source Name ✓ Correct answer
- Database System Name
-
From which object do you ask for DatabaseMetaData?
Topic: JDBC & Databases
- Connection ✓ Correct answer
- ResultSet
- DriverManager
- Driver
-
If ResultSet is TYPE_FORWARD_ONLY then it when you call to the previous () method.
Topic: JDBC & Databases
- Moves the cursor to previous row if cursor is on valid row
- Returns false if cursor is not on valid row
- Throws an exception ✓ Correct answer
- Executes normally
-
If we have created a DSN named as employeeDSN what will be the url of database:
Topic: JDBC & Databases
- "jdbc:odbc: employeeDSN" ✓ Correct answer
- "jdb_odbc: employeeDSN"
- "odbc :jdbc: employeeDSN"
- "jdbc:odbc_employeeDSN"
-
In Java, types of statement objects are available for sending SQL queries to the databases.
Topic: JDBC & Databases
- Two
- Three ✓ Correct answer
- Four
- Five
-
In ResultSetMetaData methods, _ method returns the SQL type for the column to compare against types in java.sql Types
Topic: JDBC & Databases
- getColumn Type (int) ✓ Correct answer
- getColumnCount()
- getColumnName(int)
- getColumnDisplay Size (int)
-
In ResultSetMetaData methods, method returns the number of columns in the result set.
Topic: JDBC & Databases
- getColumnCount ( ) ✓ Correct answer
- getColumnDisplaySize (int)
- getColumnLabel (int)
- getColumnType (int)
-
In ResultSetMetaData methods, method returns the suggested column label for printouts.
Topic: JDBC & Databases
- getColumnName()
- getColumnCount ()
- getColumnType (int)
- getColumnLabel() ✓ Correct answer
-
JDBC-ODBC stands for _.
Topic: JDBC & Databases
- Java DataBase Connectivity- Oracle DataBase Connectivity
- Java DataBase Corporation- Open DataBase Corporation
- Java DataBase Corporation- Oracle DataBase Corporation
- Java DataBase Connectivity- Open DataBase Connectivity ✓ Correct answer
-
Let suppose a column has index 5 in the ResultSet object. Which of the following statement is used to retrieve the column values?
Topic: JDBC & Databases
- String name = rs.getInt(4)
- String name = rs.getInt(5)
- String name = rs.getString(4)
- String name = rs.getString(5) ✓ Correct answer
-
Result set index starts from :
Topic: JDBC & Databases
- 0
- Any number
- -1
- 1 ✓ Correct answer
-
ResultSet Meta Data will help you in answering the following questions except;
Topic: JDBC & Databases
- How Many columns are in the ResultSet?
- What is the name of given column?
- How many rows are in the ResultSet? ✓ Correct answer
- Are the column name is case sensitive?
-
ResultSet provides various getters to retrieve _.
Topic: JDBC & Databases
- data of the column ✓ Correct answer
- data of the row
- data of the row and column
- column headers
-
The method returns true or false depending upon whether the next row is available (exist) or not in ResultSet.
Topic: JDBC & Databases
- getters
- next() ✓ Correct answer
- close()
- close()
-
There are steps in order to communicate successfully with database.
Topic: JDBC & Databases
- Six
- Seven
- Eight ✓ Correct answer
- Nine
-
There is a program in which main method is calling method1 () and methodNew( ) is calling methodOld() . If the exception occurs in this program, Which of the following method will handle this exception? public static void methodOld() throws IOException{ //any code }
Topic: JDBC & Databases
- MethodOld()
- methodNew() ✓ Correct answer
- main method()
- Run time system enviroment
-
When defining a method you must include a to declare any exception that might be thrown but isnot caught in the method.
Topic: JDBC & Databases
- try block
- finally block
- catch block
- throws-clause ✓ Correct answer
-
Which database allows us to work having closed connection?
Topic: JDBC & Databases
- Mysql
- PostgreSQL
- SQL
- SQLite ✓ Correct answer
-
Which of following can be thrown using the throw statement?
Topic: JDBC & Databases
- Error
- Throwable
- Exception ✓ Correct answer
- RuntimeException e. All of Given
-
Which of the following code statement is used to define a connection URL?
Topic: JDBC & Databases
- Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver)
- Connection abc = DriverManager.getConnection(conURL) ✓ Correct answer
- String asd = “jdbc:odbc:DSNname”
- Statement xyz = abc.createStatement()
-
Which of the following driver type(s) has better performance than other?
Topic: JDBC & Databases
- Type 1: JDBC - ODBC Bridge
- Type 2: Native - API/partly Java driver
- Type 3: Net - protocol/all-Java driver
- Type 4: Native - protocol/all-java driver ✓ Correct answer
-
Which of the following exceptions can be caught in a throw clause?
Topic: JDBC & Databases
- Null pointer exception
- Index out of bounds exception
- Division by zero exception
- IOException ✓ Correct answer
-
Which of the following is not the method of ResultSetMetaData class.
Topic: JDBC & Databases
- Previous() ✓ Correct answer
- isReadOnly()
- getColumnDisplay size()
- getColumnCount()
-
Which of the following method is used to execute SELECT SQL statements?
Topic: JDBC & Databases
- ExecuteUpdate(sql);
- ExecuteUpdate(sql);
- ExecuteQuery(sql); ✓ Correct answer
- Execute Query(sql);
-
Which of the following method is used to move the cursor to given row number?
Topic: JDBC & Databases
- absolute(int); ✓ Correct answer
- absolute();
- moveTolInsertRow(int);
- insertRow();
-
Which of the following method is used to release the JDBC and database resources in ResultSet?
Topic: JDBC & Databases
- next()
- getters
- previous()
- close() ✓ Correct answer
-
Which of the following method/s is a ResultSetMetaData method?
Topic: JDBC & Databases
- All of the given options ✓ Correct answer
- getColumnCount ()
- getColumnName(int)
- getColumnDisplaySize (int)
-
Which of the following methods is used to determine whether a database is read only or not?
Topic: JDBC & Databases
- isReadonty()
- isReadOnly() ✓ Correct answer
- isreadonly()
- IsReadOnly()
-
Which of the following package needs to import while interacting with relational database?
Topic: JDBC & Databases
- java.io
- java.sql ✓ Correct answer
- javax.swing
- java.awt
-
Which of the following syntax is used to get DataBaseMetaData object?
Topic: JDBC & Databases
- DataBaseMetaData md = rs.getMetaData(); // where rs is ResultSet object
- DataBaseMetaData md = st.getMetaData(); // where st is Statement object
- DataBaseMetaData md = con.getMetaData(); // where con is Connection object ✓ Correct answer
- DataBaseMetaData md = rsmd_.getMetaData(); // where rsmd is ResultSetMetaData object
-
Which of the given statement objects are used to execute using same query multiple times by only changing parameters?
Topic: JDBC & Databases
- Statement
- CallableStatement
- PreparedStatement ✓ Correct answer
- Both PreparedStatement and CallableStatement
-
__________ translates all JDBC calls into ODBC calls and send them to the ODBC Driver.
Topic: JDBC & Databases
- Type-1 ✓ Correct answer
- Type-2
- Type-3
- Type-4
-
getColumnCount() is a method of object.
Topic: JDBC & Databases
- Statement
- ResultSet
- ResultSetMetaData ✓ Correct answer
- DataBaseMetaData
-
is the correct syntax to set size of top-level container “myFrame” as 200 rows in pixel and 400 columns in pixel.
Topic: JDBC & Databases
- myFrame.setSize(200,400) ;
- myFrame.setSize(400,200) ; ✓ Correct answer
- myFrame->setSize(200,400) ;
- myFrame->setSize(400,200) ;
-
Which of the following methods are invoked by the AWT to support paint and repaint operations?
Topic: Networking, Sockets & Web Basics
- repaint() ✓ Correct answer
- paint( )
- draw()
- redraw()
-
A port is a to which processes can listen for connections request.
Topic: Networking, Sockets & Web Basics
- Local Address ✓ Correct answer
- Server Address
- Client Address
- Transport Address
-
FTP (File Transmission Protocol) works on port.
Topic: Networking, Sockets & Web Basics
- 21 ✓ Correct answer
- 23
- 80
- 84
-
HTTP lies on which of the following layer?
Topic: Networking, Sockets & Web Basics
- Presentation Layer
- Data Layer
- Network Layer
- Application Layer ✓ Correct answer
-
HTTP works on port _.
Topic: Networking, Sockets & Web Basics
- 21
- 23
- 80 ✓ Correct answer
- 84
-
How many ports are available for TCP socket?
Topic: Networking, Sockets & Web Basics
- 64
- 64k ✓ Correct answer
- 128
- 128k
-
How many ports are available for UDP socket?
Topic: Networking, Sockets & Web Basics
- 64
- 128
- 64k ✓ Correct answer
- 128k
-
How many simultaneous connections can be opened using TCP and UDP ports?
Topic: Networking, Sockets & Web Basics
- 6 4
- 1 2 8
- 64k
- 128k ✓ Correct answer
-
In Java, we can read/write to a network using sockets.
Topic: Networking, Sockets & Web Basics
- True ✓ Correct answer
- False
-
In the context of Socket Programming, the client does NOT know about the hostname of the machine on which the server is running.
Topic: Networking, Sockets & Web Basics
- True
- False ✓ Correct answer
-
Port is a transport address to which processes can for connections request.
Topic: Networking, Sockets & Web Basics
- Read
- Write
- Listen ✓ Correct answer
- None of the given options
-
Socket is a -------------- communication channel between hosts.
Topic: Networking, Sockets & Web Basics
- Uni-directional
- Bi-directional ✓ Correct answer
- Multi-directional
- None of these
-
TELNET works on port.
Topic: Networking, Sockets & Web Basics
- 21
- 23 ✓ Correct answer
- 80
- 84
-
The server just waits, listening to the socket for a client to make a connection request.
Topic: Networking, Sockets & Web Basics
- True ✓ Correct answer
- False
-
Which of the following package needs to be import while handling files?
Topic: Networking, Sockets & Web Basics
- java.util
- java.io ✓ Correct answer
- java.awt
- javax.swing
-
Which of the following range of response code signify error by server?
Topic: Networking, Sockets & Web Basics
- 200-299
- 300-399
- 400-499
- 500-599 ✓ Correct answer
-
Which of the following syntax is used to create a Server Socket?
Topic: Networking, Sockets & Web Basics
- ServerSocket ss = new ServerSocket(“serverName”);
- ServerSocket ss = new ServerSocket(serverPort); ✓ Correct answer
- ServerSocket ss = new ServerSocket(“serverName”, serverPort);
- ServerSocket ss = new ServerSocket(serverPort, “serverName”);
-
Which of the following syntax is used to create a client socket?
Topic: Networking, Sockets & Web Basics
- Socket s = new Socket(“serverName”);
- Socket s = new Socket(serverport);
- Socket s = new Socket(“serverName”, serverPort); ✓ Correct answer
- Socket s = new Socket(serverPort, “serverName”);
-
You can --------- to a network using sockets.
Topic: Networking, Sockets & Web Basics
- Read
- Write
- Read/Write ✓ Correct answer
- None of these
-
getrequest() method gets information from a client and postrequest() method posts data to a client.
Topic: Networking, Sockets & Web Basics
- True
- False ✓ Correct answer
-
Choose the correct syntax to define an interface named as "Speaker" in java language
Topic: Java Basics & OOP
- public class Speaker{}
- public interface class Speaker{}
- public interface Speaker{} ✓ Correct answer
- public Speaker class interface{}
-
To compile all the .java files, the java compiler is called ______ on UNIX or Windows.
Topic: Java Basics & OOP
- javac ✓ Correct answer
- cjava
- java.c
- c java
-
Java programs are crafted in the Editor, whereas they are saved in ____________.
Topic: Java Basics & OOP
- usb
- disk ✓ Correct answer
- primary memory
- external file
-
In Java, static methods have direct access to _______.
Topic: Java Basics & OOP
- Both static and instance members
- Instance variables
- Instance methods
- Static variables and methods ✓ Correct answer