‏إظهار الرسائل ذات التسميات Java. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات Java. إظهار كافة الرسائل
MCQ Questions on Fundamental of Java set-16

MCQ Questions on Fundamental of Java set-16


1) Java programs are ........ independent.

A. platform

B. procedural

C. high level

D. Secure


2) Methods having same name, same type signature are called ....... methods.

A. overriding

B. overloading

C. overwriting

D. over reading


3) When several tasks are handled by a single CPU, it is called .........

A. multitasking

B. task

C. simultaneous

D. taker


4) A Java program must contain a ....... method.

A. user defined

B. main

C. local

D. return


5) Package statement helps to create many classes to have ........ name.

A. differ

B. vanity

C. same

D. punch


6) Threads can be created by extending .......... class.

A. new

B. operator

C. thread

D. super thread


7) ........... operator is used to create an array.

A. new

B. public

C. key

D. main


8) A method without the body is called ......... method.

A. view

B. class

C. abstract

D. user defined


9) Threads can be created by implementing ......... interface.

A. new

B. create

C. main

D. runnable


10) An instance of a class is ........

A. method

B. initialize

C. declared

D. object

11) The wrapper classes are defined in ........ packages.

A. java.Lan

B. java.Lang

C. java.Nill

D. java.Math


12) What is an example of polymorphism?

A. inner class

B. anonymous classes

C. method overloading

D. method overriding


13) The variable in class is called ........ variable

A. local

B. minimum

C. instance

D. define


14) User defined exception can be created using ..........class.

A. catch

B. try

C. throwable

D. get


15) To compare the contents of two objects ........ method is used.

A. equals

B. non equals

C. multiple

D. delay


16) A special type of method that is used to initialize an object is called..........

A. constructor

B. destructor

C. modification

D. editor


17) An abnormal condition occurring in a Java program is called ......

A. error

B. viewer

C. abstract

D. exception


18) Graphics object can only be drawn on ........

A. view

B. windows

C. applet

D. zoom


19) String constants are said to be .......... of string class.

A. objects

B. char

C. data

D. variable


20) Exception that is identified during compile time is called ......... exception.

A. user defined

B. checked

C. undefined

D. defined

Answers:

1) A. platform
2) A. overriding
3) A. multitasking
4) B. main
5) C. same
6) C. thread
7) A. new
8) C. abstract
9) D. runnable
10) D. object
11) B. java.Lang
12) C. method overloading
13) C. instance
14) C. throwable
15) A. equals
16) A. constructor
17) D. exception
18) B. windows
19) A. objects
20) B. checked


Related Posts:

Interview Questions on Core Java Language set-3

Interview Questions on Core Java Language set-3


1) The CODE value in an ......... tag must name a class file that is in the same directory as the calling HTML page.

A. (applet)

B. >applet<

C. <applet>

D. <applet tag>


2) A class can be converted to a thread by implementing the interface ..........

A. Thread

B. Runnable

C. Start

D. Yield


3) Which of the following classes are not available in the java.lang package?

A. Stack

B. Object

C. Math

D. String


4) State True or False for the following statements.

i) Reader class has a method that can read and return floats and doubles

ii) It is possible to use the File class to list the contents of the current of the working directory

A. i-True, ii-False

B. i-False, ii-True

C. i-True, ii-True

D. i-False, ii-False


5) The setBackground() method is part of the following class in JAVA.awt package.

A. Component

B. Graphics

C. Applet

D. Container


6) Which method is used to set the text of a Label object?

A. setText()

B. setLabel()

C. setTextLabel()

D. setLabelText()


7) Which of the following statement is/are True?

i) A Java monitor must either extend Thread class or implement Runnable interface

ii) The CheckboxGroup class is a subclass of the component class

A. i- only

B. ii- only

C. Both i and ii

D. None of the above


8) When we invoke repaint() for JAVA.awt.Component object, the AWT invokes the method .......

A. update()

B. draw()

C. show()

D. paint()


9) Which of the following methods are invoked by the AWT to support paint and repaint operations?

A. paint()

B. repaint()

C. draw()

D. redraw()


10) A thread can make a second thread ineligible for execution by calling the ......... method on the second thread.

A. second()

B. suspend()

C. append()

D. yield()

11) When we implement the Runnable interface, we must define the method

A. run()

B. start()

C. init()

D. main()


12) Which of the following are passed as an argument to the paint() method?

A. A Canvas object

B. A Graphics object

C. An image object

D. A paint object


13) State whether the following statements are True or False.

i) A class may be both abstract and final

ii) A final class may not have any abstract methods

iii) Frames and applets cannot be used together in the same program.

A. i-True, ii-True, iii-False

B. i-True, ii-False, iii-True

C. i-False, ii-True, iii-False

D. i-False, ii-True, iii-True


14) The methods wait() and notify() are defined in?

A. java.lang.String

B. java.lang.Object

C. java.lang.Runnable

D. java.lang.Thread


15) Which of the following components generate action events?

A. Buttons

B. Labels

C. Check boxes

D. Windows


16) Which javadoc tag is used to denote a comment for a method parameter?

A. @method

B. @parameter

C. @arjument

D. @param


17) Which of the following are not the wrapper classes?

A. Byte

B. Vector

C. Integer

D. Short


18) Which of the following classes is used to perform basic console I/O?

A. system

B. security Manager

C. math

D. runtime


19) Which of the following command lines options generates documentation for all classes and methods?

A. -protected

B. -public

C. -private

D. -verbose


20) What is java_g used for?

A. Using the jdb tool

B. Executing a class with optimization turned off

C. To provide information about deprecated methods

D. None of the above

Answers:

1) C. <applet>
2) B. Runnable
3) A. Stack
4) A. i-True, ii-False
5) A. Component
6) A. setText()
7) D. None of the above
8) A. update()
9) A. paint()
10) C. append()
11) A. run()
12) B. A Graphics object
13) C. i-False, ii-True, iii-False
14) B. java.lang.Object
15) A. Buttons
16) D. @param
17) B. Vector
18) A. system
19) C. -private
20) B. Executing a class with optimization turned off


Related Posts:

Interview Questions on Overview of Java set-15

Interview Questions on Overview of Java set-15


1) Object is an ........ of class.

A. instance

B. implement

C. inheritance

D. invoke


2) ....... is the wrapper class.

A. Random

B. Byte

C. Vector

D. String


3) Class is a ........ entity.

A. logical

B. Physical

C. up normal

D. collection of


4) Which of the following denotes a javadoc comment?

A. //#

B. /*

C. /**

D. //**


5) Object is a ........ entity.

A. normal

B. physical

C. logical

D. normal


6) One interface can inherit another by use of the keyword ........

A. public

B. extends

C. method name

D. class name


7) ......... must be the first non comment statement in the file

A. package

B. class

C. object

D. declaration


8) In java thread to thread communication is called ....

A. passing

B. sending

C. messaging

D. calling


9) Every method of a ........... is implicitly final.

A. static class

B. dynamic class

C. final class

D. abstract class


10) The string is defined in ......... name space.

A. java.Lang

B. java.String

C. java.Char

D. java.Awt



11) A ......... object cannot be modified after it is created.

A. double

B. int

C. string

D. main


12) ......... is a special member function.

A. method

B. class

C. use defined function

D. constructor


13) A ........ class may not have any abstract method.

A. abstract

B. static

C. final

D. public


14) Keyword .......... is always a reference to the object.

A. new

B. this

C. invoke

D. class


15) ......... operators are overloaded for string objects?

A. -,+

B. +,=

C. <<,>>

D. ++,--


16) ....... is a small unit of process.

A. method

B. thread

C. applet

D. steam


17) ....... is valid for if statement?

A. An integer expression

B. A Boolean expression

C. A character expression

D. A legal expression


18) Wrapper class is a wrapper around a ....... data type.

A. normal

B. central

C. primitive

D. concrete


19) ........ statement is valid for array declaration.

A. int number();

B. float number();

C. float number[];

D. count int[];


20) ....... operators which concatenates two strings.

A. +

B. ++

C. -

D. +-

Answers:

1) A. instance
2) B. Byte
3) A. logical
4) C. /**
5) B. physical
6) B. extends
7) A. package
8) C. messaging
9) C. final class
10) A. java.Lang
11) C. string
12) D. constructor
13) C. final
14) B. this
15) B. +,=
16) B. thread
17) B. A Boolean expression
18) C. primitive
19) C. float number[];
20) A. +

Related Posts:

Solved MCQ on Fundamental of Java Language set-14

Solved MCQ on Fundamental of Java Language set-14


1) Which of the following statement is/are true?
i) The name of a java program file must match the name of the class with the extension .java
ii) Two methods cannot have the same name in java

A. i- only

B. ii- only

C. Both i and ii

D. None of the above


2) Which of the following represent(s) of a hexadecimal number?

A. 570

B. (hex)5

C. 0X9F

D. 0X5


3) ........ can appear only where in the body of a java method.

A. definition

B. declaration

C. determine

D. package


4) State whether the following statement are True or False?
i) The modulus operator(%) can be used only with integer operands
ii) Declarations can appear anywhere in the body of a java method

A. i-True, ii-False

B. i-False, ii-True

C. i-True, ii-True

D. i-False, ii-False


5) Which of the following will produce a value of 22 if x=22.9?

A. ceil(x)

B. round(x)

C. rint(x)

D. abs(x)


6) ........ is passed to a method by use of call by reference.

A. Variables

B. Objects

C. Methods

D. Operators


7) Using the keyboard interface you can fully abstract a ...

A. Method

B. Keyword

C. Class

D. Variables


8) State True or False for the following statements in java.
i) All the bitwise operators have same level of precedence in java
ii) The default can is always required in the switch selection structure.

A. i-True, ii-False

B. i-False, ii-True

C. i-True, ii-True

D. i-False, ii-False


9) Java is designed for .......... environment of the Internet.

A. Development

B. Deduction

C. Distributed

D. Web Design


10) Which of the following will produce a value of 10 if x=9.7?

A. floor(x)

B. abs(x)

C. rint(x)

D. round(x)

11) Variable declared as ......... do not occupy on a per instance basis.

A. Static

B. Final

C. Abstract

D. Code


12) Which of the following is not keyword?

A. NULL

B. implements

C. protected

D. switch


13) The ...... statement is used to terminate a statement sequence.

A. Break

B. Switch

C. Continue

D. Wait


14) Multidimensional arrays are actually ......

A. Arrays of element

B. Arrays of variable

C. Arrays of arrays

D. Arrays of variable


15) Which of the following keywords are used to control access to a class member?
i) default ii) abstract iii) protected iv) interface v) public

A. i, ii and iii only

B. ii, iii and iv only

C. iii, iv and v only

D. ii, iii and v only


16) ....... is used for initialize the value to the string object.

A. Character literals

B. String literals

C. String group literals

D. Group literals


17) Which of the following methods can be used to remove a component from the display?

A. delete()

B. remove()

C. disappear()

D. hide()


18) Which of the following statements are valid array declaration?
i) int number(); ii) float average[ ];
iii) double[]marks; iv) counter int[];

A. i and ii

B. ii and iii

C. iii and iv

D. All i, ii, iii and iv


19) Which of the following methods belong to the String class?

A. length()

B. CompareTo()

C. equals()

D. substring()

E. All of the above


20) Which of the following in NOT represent legal flow control statements?

A. break;

B. break();

C. continue outer;

D. return;


Answers:

1) A. i- only
2) A. 570
3) B. declaration
4) B. i-False, ii-True
5) C. rint(x)
6) B. Objects
7) C. Class
8) D. i-False, ii-False
9) C. Distributed
10) D. round(x)
11) B. Final
12) A. NULL
13) A. Break
14) C. Arrays of arrays
15) D. ii, iii and v only
16) B. String literals
17) D. hide()
18) B. ii and iii
19) E. All of the above
20) B. break();

Related Posts:

MCQ on Core Java with Answers set-1

MCQ on Core Java with Answers set-1


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




Related Posts:



MCQ on Java Programming Language Fundamental set-12

MCQ on Java Programming Language Fundamental set-12


1. A java program is first ................ and ...................

A) executed, run

B) compiled, run

C) run, compiled

D) interpreted, compiled


2. Byte code is also a ...........

A) machine code

B) bit code

C) cryptographic code

D) none


3. A private class is accessible from inside a .................

A) package

B) class

C) method

D) none


4. Consider the statement "x=(a>b)?a:b", then the value of x is 19, if a=19 and b=12

A) true

B) not supported

C) false

D) none of the above


5. Adapter classes are used for ...............

A) code redundancy

B) code reduction

C) code organization

D) none


6. ..................... inheritance is enable by interface in java.

A) min level

B) multiple

C) low level

D) none


7. .................... is generated if a button is clicked in AWT.

A) ItemEvent

B) WindowEvent

C) ActionEvent

D) MouseEvent


8. Using which keyword we can access value of the instance and class variables of that class inside the method of that class itself.

A) super

B) final

C) this

D) either super or this


9. If a variable is declared FINAL, it must include ......................... value.

A) integer

B) number

C) initial

D) float


10. In java, string is a

A) primitive data type

B) abstract data type

C) combination of boolean

D) None of the above


11. Methods can be overloaded with a difference only in the type of the return value

A) Not supported

B) False

C) True

D) None of the above


12. Each method in a java class must have a unique name

A) Not necessarily

B) True

C) False

D) None of the above


13. It is an important feature of java that it always provides a default constructor to a class

A) Not supported

B) False

C) True

D) None of the above


14. If one or more abstract methods are not implemented in an abstract class, then the subclass is also abstract.

A) Not necessarily

B) False

C) True

D) None of the above


15. Life cycle of an applet is described by .................. methods.

A) six

B) three

C) four

D) five


16. Which of the following is not subclass of "writer" stream.

A) FileWriter

B) LineWriter

C) BufferedWriter

D) PrintWriter


17. In java RMI, stub is located in

A) client machine

B) proxy

C) server

D) none of the above


18. The new keyword will

i) create in instance of an object

ii) create instance of a class

iii) assign memory to an array

iv) call the destructor of a class

A) i and iii

B) ii and iii

C) i and ii

D) ii, iii and iv


19. ODBC stands for

A) Object Data Binding Command

B) Open Database Console

C) Open Database Connectivity

D) Open Database Command


20. Continue statement can be used

i) anywhere inside main method

ii) anywhere inside class

iii) within instance methods

iv) only within looping statements

A) i, ii and iii

B) i and iv

C) only iv

D) ii, iii and iv





Show/Hide Answers:




1. A java program is first ................ and ...................

B) compiled, run

2. Byte code is also a ...........

D) none

3. A private class is accessible from inside a .................

B) class

4. Consider the statement "x=(a>b)?a:b", then the value of x is 19, if a=19 and b=12

A) true

5. Adapter classes are used for ...............

B) code reduction

6. ..................... inheritance is enable by interface in java.

B) multiple

7. .................... is generated if a button is clicked in AWT.

C) ActionEvent

8. Using which keyword we can access value of the instance and class variables of that class inside the method of that class itself.

C) this

9. If a variable is declared FINAL, it must include ......................... value.

C) initial

10. In java, string is a

B) abstract data type

11. Methods can be overloaded with a difference only in the type of the return value

B) False

12. Each method in a java class must have a unique name

A) Not necessarily

13. It is an important feature of java that it always provides a default constructor to a class

C) True

14. If one or more abstract methods are not implemented in an abstract class, then the subclass is also abstract.

C) True

15. Life cycle of an applet is described by .................. methods.

C) four

16. Which of the following is not subclass of "writer" stream.

B) LineWriter

17. In java RMI, stub is located in

A) client machine

18. The new keyword will

i) create in instance of an object

ii) create instance of a class

iii) assign memory to an array

iv) call the destructor of a class

A) i and iii

B) ii and iii

C) i and ii

D) ii, iii and iv

19. ODBC stands for

A) Object Data Binding Command

B) Open Database Console

C) Open Database Connectivity

D) Open Database Command

20. Continue statement can be used

i) anywhere inside main method

ii) anywhere inside class

iii) within instance methods

iv) only within looping statements

C) only iv



Related Posts:


MCQ on Java Programming With Answers set-11

MCQ on Java Programming With Answers set-11


1. If m and n are int type variables, what will be the result of the expression m%n when m=-14 and n=-3?

A) 4

B) 2

C) -2

D) -4



2. Consider the following code

if(number>=0)

if(number>0)

system.out.println("Number is positive");

else

system.out.println("Number is negative");

What will be the output if number is equal to 0?

A) Number is negative

B) Number is positive

C) Both A and B

D) None of the above



3. Consider the following code:

char c='a';

switch (c)

{
case 'a';

system.out.println("A");

case 'b';

system.out.println("B");

default;



system.out.println("C");
}

For this code, which of the following statement is true?

A) Output will be A

B) Output will be A followed by B

C) Output will be A, followed by B, and then followed by C

D) Code is illegal and therefore will not compile



4. Consider the following class definition.

class Student extends String

{
}

What happens when we try to compile this class?


A) Will not compile because class body is not defined

B) Will not compile because the class in not declared public.

C) Will not compile because string is abstract.

D) Will not compile because string is final.



5. What is wrong in the following class definitions?

abstract class print

{
abstract show();
}
class Display extends Print
{
}

A) Nothing is wrong

B) Wrong. Method show() should have a return type

C) Wrong. Method show() is not implemented in Display

D) Wrong. Display does not contain any numbers.



6. What is the error in the following class definitions?

abstract class XY
{
abstract sum(int x, int y){ }
}

A) Class header is not defined properly

B) Constructor is not defined

C) Method is not defined properly

D) No error.




7. Which of the following statements are true?

i) We cannot use abstract classes to instantiate objects directly.

ii) The abstract methods of an abstract class must be defined in its subclass.

iii) We cannot declare abstract constructors.

iv) We may declare abstract static methods.

A) Line i only

B) Line ii only

C) Line i and ii only

D) Line i, ii and iii only




8. We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would archive this?

A) Private

B) Protected

C) Public

D) Private Protected




9. The use of protected keyword to a member in a class will restrict its visibility as follows:

A) Visible only in the class and its subclass in the same package.

B) Visible only inside the same package.

C) Visible in all classes in the same package and subclasses in other packages

D) Visible only in the class where it is declared.




10. Consider the following code:

interface Area
{
float compute (float x, float y);
}
class Room implements Area
{
float compute (float x, float y)

{
return(x&y);
}
}

What is wrong with the code?

A) Interface definition is incomplete

B) Method compute() in interface Area should be declared public

C) Method compute() in class Room should be declared public

D) All the above






Answers:



1. If m and n are int type variables, what will be the result of the expression m%n when m=-14 and n=-3?

C) -2


2. Consider the following code

if(number>=0)
if(number>0)
system.out.println("Number is positive");
else
system.out.println("Number is negative");

What will be the output if number is equal to 0?

A) Number is negative


3. Consider the following code:

char c='a';
switch (c)
{
case 'a';
system.out.println("A");
case 'b';
system.out.println("B");
default;
system.out.println("C");
}

For this code, which of the following statement is true?

B) Output will be A followed by B


4. Consider the following class definition.

class Student extends String
{
}

What happens when we try to compile this class?

D) Will not compile because string is final.


5. What is wrong in the following class definitions?

abstract class print
{
abstract show();
}
class Display extends Print
{
}

C) Wrong. Method show() is not implemented in Display


6. What is the error in the following class definitions?

abstract class XY
{
abstract sum(int x, int y){ }
}


C) Method is not defined properly


7. Which of the following statements are true?

i) We cannot use abstract classes to instantiate objects directly.

ii) The abstract methods of an abstract class must be defined in its subclass.

iii) We cannot declare abstract constructors.

iv) We may declare abstract static methods.

D) Line i, ii and iii only


8. We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would archive this?

D) Private Protected


9. The use of protected keyword to a member in a class will restrict its visibility as follows:

C) Visible in all classes in the same package and subclasses in other packages


10. Consider the following code:

interface Area
{
float compute (float x, float y);
}
class Room implements Area
{
float compute (float x, float y)
{
return(x&y);
}
}

What is wrong with the code?

C) Method compute() in class Room should be declared public




Related Posts



For other more Multiple Choice Questions (MCQs): Click Here

JDBC MCQ Interview Questions with Answers set-2

JDBC MCQ Interview Questions with Answers set-2


1. A Java program cannot directly communicate with an ODBC driver because .......
JDBC MCQ Interview Questions with Answers
ODBC Administrator (Photo credit: Wikipedia)

A) ODBC written in C language

B) ODBC written in C# language

C) ODBC written in C++ language

D) ODBC written in Basic language



2.The JDBC-ODBC Bridge driver translates the JDBC API to the ODBC API and used with .......


A) JDBC drivers

B) ODBC drivers

C) Both A and B

D) None of the above



3. The ............................. package contains classes that help in connecting to a database, sending SQL statements to the database, and processing the query results.

A) connection.sql

B) db.sql

C) pkg.sql

D) java.sql



4. The ................................ method executes a simple query and returns a single Result Set object.

A) executeUpdate()

B) executeQuery()

C) execute()

D) noexecute()



5. The ......................... method executes an SQL statement that may return multiple results.

A) executeUpdate()

B) executeQuery()

C) execute()

D) noexecute()




6. The ........................ object allows you to execute parametrized queries.

A) ResultSet

B) Parametrized

C) PreparedStatement

D) Condition



7. The .................. object provides you with methods to access data from the table.

A) ResultSet

B) Parametrized

C) TableStatement

D) Condition



8. The parameters of the PreparedStatement object are ...................... when the user clicks on the Query button.

A) initialized

B) started

C) paused

D) stopped



9. The ...................... method sets the query parameters of the PreparedStatement Object.

A) putString()

B) insertString()

C) setString()

D) setToString()



10. Connection object can be initialized using the ............................ method of the Driver Manager class.

A) putConnection()

B) setConnection()

C) Connection()

D) getConnetion()





Answers:



1. A Java program cannot directly communicate with an ODBC driver because .......

A) ODBC written in C language

2.The JDBC-ODBC Bridge driver translates the JDBC API to the ODBC API and used with .......

B) ODBC drivers

3. The ............................. package contains classes that help in connecting to a database, sending SQL statements to the database, and processing the query results.

D) java.sql

4. The ................................ method executes a simple query and returns a single Result Set object.

B) executeQuery()

5. The ......................... method executes an SQL statement that may return multiple results.

C) execute()

6. The ........................ object allows you to execute parametrized queries.

C) PreparedStatement

7. The .................. object provides you with methods to access data from the table.

A) ResultSet

8. The parameters of the PreparedStatement object are ...................... when the user clicks on the Query button.

A) initialized

9. The ...................... method sets the query parameters of the PreparedStatement Object.

C) setString()

10. Connection object can be initialized using the ............................ method of the Driver Manager class.

D) getConnetion()



Related Posts:

Java MCQ Interview Questions With Answers set-10

Java MCQ Interview Questions With Answers set-10


1. Java was developed by the company

A) Sun Micro systems
Image representing Sun Microsystems as depicte...
Sun Micro systems Image CrunchBase

B) Microsoft

C) Micro tech

D) IBM



2. What is the file extension of compiled java program?

A) .class

B) .java

C) .css

D) .html



3. .................. keyword is used to invoke the current object.

A) New

B) That

C) This

D) Me



4. Which of the function is used to convert string to Number in java program?

A) to Number()

B) conString()

C) valueOf()

D) toString()


5. What are the part in executing a Java program and their purposes?

A) Java Compiler

B) Java Interpreter

C) Java Pre-processor

D) Directive Pre-processor


6. Method overloading is one of the way that Java supports ............

A) encapsulation

B) class

C) inheritence

D) polymorphism


7. Java support RMI. What does this RMI stands for?

A) Random Memory Interface

B) Remote Method Invocation

C) Random Method Invocation

D) Remote Memory Interface


8. Which of the following represent legal flow control statements?

A) break;

B) break();

C) continue(inner);

D) exit();


9. The keywords reserved but used in the initial version of Java are

A) union

B) const

C) inner

D) goto


10. What is the default return type of main() ..

A) void

B) double

C) float

D) int



Answers:



1. Java was developed by the company

A) Sun Micro systems

2. What is the file extension of compiled java program?

A) .class

3. .................. keyword is used to invoke the current object.

C) This

4. Which of the function is used to convert string to Number in java program?

C) valueOf()

5. What are the part in executing a Java program and their purposes?

A) Java Compiler

6. Method overloading is one of the way that Java supports ............

D) polymorphism

7. Java support RMI. What does this RMI stands for?

B) Remote Method Invocation

8. Which of the following represent legal flow control statements?

A) break;

9. The keywords reserved but used in the initial version of Java are

A) union

10. What is the default return type of main() ..

D) int


Related Posts


Java Objective Questions with Answers set-9

Java Objective Questions with Answers set-9


1. In java a ....................... is a sequence of characters.

Java Objective Questions with Answers
Schema of the general architecture of a program running in a Java Virtual Machine (Photo credit: Wikipedia)

A) string

B) arrayChar

C) groupChar

D) collection



2. Java programs perform I/O through ...........

A) I/O methods

B) I/O package

C) streams

D) compiler



3. What is byte code in the context of Java?

A) The type of code generated by a Java compiler

B) The type of code generated by a Java Virtual Machine

C) It is another name for Java source file

D) It is the code written within the instance methods of a class



4. Which of the following statements about abstract methods/classes in Java is true?

A) An abstract class cannot be instantiated.

B) Constructors can be abstract.

C) A subclass of an abstract class must defined the abstract methods.

D) Static methods may be declared abstract.



5. Which of the following statement is false?

A) The sleep() method should be enclosed in try ......... catch block

B) The yield() method should be enclosed in try ......... catch block.

C) A thread can be temporarily suspended from running by using the wait() method.

D) A suspended thread using suspend() method can be revived using the resume() method.



6. The new operator dynamically allocates ..............for an object and returns a reference to it.

A) classes

B) variables

C) memory

D) none of the above



7. Which of the following statements correctly describes an interface?

A) It's a concrete class

B) It's a super class

C) It's a type of abstract class

D) It's a subclass



8. What is the priority of the Garbage collector thread of jdk?

A) Low Priority

B) Highest Priority

C) Medium Priority

D) Decided at run time



9. ................ is a feature that allows one interface to be used for a general class of actions.

A) Class

B) Inheritance

C) Polymorphism

D) Interface



10. The default package that is implicitly called in a java program is .............

A) java.Lang

B) java.System

C) java.Window

D) java.Lang.System



Answers:



1. In java a ....................... is a sequence of characters.

B) arrayChar

2. Java programs perform I/O through ...........

C) streams

3. What is byte code in the context of Java?

A) The type of code generated by a Java compiler

4. Which of the following statements about abstract methods/classes in Java is true?

A) An abstract class cannot be instantiated.

5. Which of the following statement is false?

B) The yield() method should be enclosed in try ......... catch block.

6. The new operator dynamically allocates ..............for an object and returns a reference to it.

C) memory

7. Which of the following statements correctly describes an interface?

C) It's a type of abstract class

8. What is the priority of the Garbage collector thread of jdk?

A) Low Priority

9. ................ is a feature that allows one interface to be used for a general class of actions.

C) Polymorphism

10. The default package that is implicitly called in a java program is .............

A) java.Lang



Related Posts


Solved MCQ of JDBC and JSP set-1

Solved MCQ of JDBC and JSP set-1

English: JDBC type 3 driver (Network Protocol ...
English: JDBC type 3 driver (Network Protocol driver) (Photo credit: Wikipedia)

1. What is JDBC?

A) java compiler

B) Java API

C) Java interpreter

D) Both A and B



2. JDBC is a ..................... interface, which means that it is used to invoke SQL commands directly

A) low-level

B) middle-level

C) higher-level

D) user



3. ODBC is not appropriate for direct use from java because it uses a ..............

A) C interface

B) C# interface

C) java interface

D) Both A and C



4. Java Soft provides ................. JDBC product components as part of the java Developer's Kit (JDK)

A) three

B) two

C) four

D) single



5. Kind of driver converts JDBC calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS is known as

A) JDBC-Net pure Java driver

B) JDBC-ODBC Bridge plus ODBC driver

C) Native-API partly-Java driver

D) Both A and B



6. JSP stands for ..........................

A) Java server Pages

B) Java server Programming

C) Java Server Process

D) Java Socket Programming



7. JSP includes a mechanism for defining ............................... or custom tags.

A) static attributes

B) local attributes

C) dynamic attributes

D) global attributes



8. JSP is not governed by the syntax and semantics defined by the ................... specifications.

A) Java 2

B) Java 2.4

C) Java 1

D) Java 1.2
 


9. JSP containers are required to support ..................... different formats of JSP syntax.

A) Two

B) Three

C) Four

D) Only One



10. The difference between Servlets and JSP is the ................

A) translation

B) compilation

C) syntax

D) Both A and B


Answers:

1.   B) Java API
2.   A) low-level
3.   A) C interface
4.   A) three
5.   C) Native-API partly-Java driver
6.   A) Java server Pages
7.   C) dynamic attributes
8.   A) Java 2
9.   A) Two
10. C) syntax

You Might also view the following Related Posts

Enhanced by Zemanta
Solved MCQ of Java Beans set-1

Solved MCQ of Java Beans set-1


1. Java Servlets are efficient and powerful solution for creating ....................... for the web.

A) dynamic content

B) static content

C) hardware

D) both and b


2. Filters were officially introduced in the servlet ........................ specification.

A) 2.1

B) 2.3

C) 2.2

D) 2.4


3. ..................... is the first phase of the servlet life cycle.

A) Initialization

B) Service

C) Destruction

D) Both a and b


4. The service phase of the servlet life cycle represents all interactions with requests until the servlet is ......................

A) created

B) running

C) initiated

D) destroyed


5. GET methods are great for sending .................... amounts of information that you do not mind having visible in a URL.

A) negligible

B) huge

C) small

D) both and b


6. Several vendors are adding ...................... to their existing database .................

A) JDOBC, middle-ware products

B) JDBC drivers, upper-ware products

C) middle-ware products, JDOBC drivers

D) JDBC drivers, middle-ware products


7. JSP is not governed by the ................... defined by the Java 2 specifications.

A) syntax and semantics

B) rules and regulation

C) Jakarta tomcat

D) compiler


8. The concept of distributed object computing can be termed as a marriage between ............. and ..................

A) C++, java

B) C, C++

C) Networking, Object-oriented programming

D) C, Object-oriented programming


9. The IDL compiler generates ..................... and .........................

A) runnable code, stubs

B) client, stubs

C) stubs, client

D) stubs, skeleton


10. Objects are units of encapsulation of ................ and ..............

A) Data, behavior

B) data types, data values

C) function definition and function declaration

D) class and method

Answers:

1.  A) dynamic content
2.  B) 2.3
3.  A) Initialization
4.  D) destroyed
5.  C) small
6.  D) JDBC drivers, middle-ware products
7.  A) syntax and semantics
8.  C) Networking, Object-oriented programming
9   D) stubs, skeleton
Java Multiple Choice Questions With Answers set-8

Java Multiple Choice Questions With Answers set-8


1. Using which keyword we can access value of the instance variables and class variables of that class inside the method of that class itself.

A) super

B) final

C) this

D) either super or this


2. If a variable is declared final, it must include ...................... value.

A) integer

B) no

C) initial

D) float


3. 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-false, iii-false, iv-true


4. In java, string is a .............

A) primitive data type

B) abstract data type

C) combination of boolean

D) None of the above


5. Methods can be overloaded with a difference only in the type of the return value ..

A) Not supported

B) False

C) True

D) None of the above


6. Each method in a java class must have a unique name .

A) Not necessary

B) True

C) False

D) None of the above


7. State true or false.

i) comparisons precede logical operations in java

ii) assignment operations succeed increment operations

iii) arithmetic operations succeed comparisons

iv) x precede +

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

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

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

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


8. It is important feature of java that it always provides a default constructor to a class.

A) Not supported

B) False

C) True

D) None of the above


9. ....................... is the key to ..................

A) Serialization, persistence

B) Persistence, inheritance

C) Inheritance, object

D) Persistence, serialization


10. State true of 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) i-true, ii-true, iii-false, iv-true

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

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

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

Answers:

1.  C) this
2.  C) initial
3.  C) i-false, ii-true, iii-false, iv-false
4.  B) abstract data type
5.  B) False
6.  A) Not necessary
7.  A) i-true, ii-true, iii-false, iv-true
8.  C) True
9.  A) Serialization, persistence
10.C) i-false, ii-true, iii-false, iv-false

You Might also view the following Related Posts

MCQ of Java With Answer set-7

MCQ of Java With Answer set-7


1. The .................. and .................... classes are abstract classes that support reading and writing of byte streams.
A) reader, writer
B) inputstream, outputstream
C) objectinputstream, objectoutputstream
D) none

2. What is the error in the following code?
     class Test
     {
         abstract void display( );
     }

A) No error
B) Method display( ) should be declared as static
C) Test class should be declared as abstract
D) Test class should be declared as public

3. A package is a collection of
A) classes
B) interfaces
C) editing tools
D) classes and interfaces

4. Which of the following methods belong to the string class?
A) length( )
B) compare To ( )
C) equals ( )
D) All of them

5. What will be the output of the following code?
    byte x=64, y;
    y= (byte) (x<<2);
    System.out.println(y);

A) 0
B) 1
C) 2
D) 64

6. If m and n are int type variables, what will be the result of the expression
    m%n
    when m=5 and n=2 ?
A) 0
B) 1
C) 2
D) None of the above

7. Which of the following control expressions are valid for an if statement?
A) An integer expression
B) A Boolean expression
C) Either A or B
D) Neither A nor B

8. The concept of multiple inheritance is implemented in Java by
A) extending two or more classes
B) extending one class and implementing one or more interfaces
C) implementing two or more interfaces
D) both B and C

9. Which of the following do not represent legal flow control statements?
A) break;
B) return;
C) exit();
D) continue outer;

10. Data input is
A) an abstract class defined in java.io
B) a class we can use to read primitive data types
C) an interface that defines methods to open files.
D) an interface that defines methods to read primitive data types.

Answers:

1.  B) inputstream, outputstream
2.  C) Test class should be declared as abstract
3.  D) classes and interfaces
4.  D) All of them 
5.  A) 0
6.  B) 1
7.  B) A Boolean expression
8.  D) both B and C
9.  C) exit();
10.D) an interface that defines methods to read primitive data types.


You Might also view the following Related Posts

Java Multiple Choice Questions With Answers set-6

Java Multiple Choice Questions With Answers set-6

1. JSP embeds in ................ in ......................
A) Servlet, HTML
B) HTML, Java
C) HTML, Servlet
D) Java, HTML

2. The class at the top of exception class hierarchy is ..........................
A) ArithmeticException
B) Throwable
C) Class
D) Exception

3. In a java program, package declaration .................... import statements.
A) must precede
B) must succeed
C) may precede or succeed
D) none

4. The class string belongs to ................... package.
A) java.awt
B) java.lang
C) java.applet
D) java.string

5. ............... package is used by compiler itself. So it does not need to be imported for use.
A) java.math
B) java.awt
C) java.applet
D) java.lang

6. State true or false for the following statements in Java.
i) Java beans slow down software development process.
ii) Java Servlets do not have built in multithreading feature.
A) i-false, ii-false
B) i-false, ii-true
C) i-true, ii-false
D) i-true, ii-true

7. State whether true or false.
i) init( ) of servlet is called after a client request comes in 
ii) Servlets are ultimately converted into JSP
A) i-false, ii-false
B) i-false, ii-true
C) i-true, ii-false
D) i-true, ii-true

8. What will be the result of compiling following code.
public class MyClass{
     public static void main(String args[]){
           System.out.println("In first main()");
     }
public static void main(char args[]){
          System.out.println('a');
     }
}

A) Code will not compile and will give "Duplicate main() method declaration" error
B) Code will compile correctly but will give a runtime  exception
C) Code will compile correctly and will print "In first main()" (without quotes) when it is run
D) Code will compile correctly and will print "a" (without quotes) when it is run

9.Match the following. 
a) Java                      1) is a tool for debugging java program
b) Javah                    2) is a tool for creating C-like header files
c) Javap                    3) runs java bytecode
d) jdb                        4) prints java code representation

A) a-3, b-2,c-1
B) a-3, b-2, c-4, d-1
C) a-1, b-2, c-3, d-4
D) a-2, b-1, c-3, d-4

10.State true or false.
i) init() is called after start() in applet
ii) applets are used for networking
iii) inheritance is a part of Java Foundation Classes
iv) final does not prevent inheritance

A) i-true, ii-true, iii-false, iv-true
B) i-false, ii-false, iii-false, iv-false
C) i-true, ii-true, iii-true, iv-true
D) i-true, ii-false, iii-false, iv-false

Answers:

1.  D) Java, HTML
2.  B) Throwable
3.  A) must precede
4.  B) java.lang
5.  D) java.lang
6.  A) i-false, ii-false
7.  A) i-false, ii-false
8.  C) Code will compile correctly and will print "In first main()" (without quotes) .. run
9.  B)  a-3, b-2, c-4, d-1
10.B) i-false, ii-false, iii-false, iv-false

You Might also view the following Related Posts