GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Please Answer these Questions of java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

Please Answer these Questions of java.

Santanu kumar Acharya
Greenhorn

Joined: Aug 08, 2012
Posts: 1

1.Which of the following methods is not defined in the java.util.Vector class?


Contains()

toString()

isEmpty()

empty()

addElement()

elementAt()



2.Which of the following methods is used while passing or returning a java object from the native method?


System.loadClass

System.loadNative

System.loadLibrary

System.callNative



3.Which of the following exceptions is not a checked exception?


ClassNotFoundException

CloneNotSupportedExeorion

NoSuchMethodException

NullPointerException

IllegalAccessException



4.Which of the following is a valid constructor for the DataInputStream class?


DataInputStream(FileInputStream fin)

DataInputStream(String str)

DataInputStream(File file)

DataInputStream(FileInputStream fin, int size)


5.Which of the following methods is available in the StringBuffer class but not in the String class?


Spilt()

reverse()

regionMatches()

offsetByCodePoints()



6.How many methods are defined by the serializable Interface?


One

Three

Four

None



7.____________ is a highly optimized set of instructions designed to be executed by the Java run-time system.


Bytecode

Firewall

Tetra code


8.There are _____ types of Comments in Java.


One

Two

Three

Four



9.Which of the following statements are true about coupling and cohesion? Each correct answer represents a complete solution. Choose all that apply


High cohesion is necessary to create a well-defined application.
Loose coupling is necessary to create a well-defined application.
High coupling is necessary to create a well-designed application.
Low coupling is necessary to create a well-designed application.


10.Sam works as a software developer for Amrtech info. He writes code using assert as an identifier for a class named KeyTest. Which of the following will he use to compile the KeyTest class successfully?


Javac –source 1.4 KeyTest.java
Javac –source 1.5 KeyTest.java
Javac –source 5 KeyTest.java



11.The ability of an object to store data beyond the life time of the object is called __________


Resistance

Persistence

Reliability

Durability



12.Which of the following are the classes from which another class inherits its behavior.


Super class

Sub class

Parent class
Child class



13.Overloaded methods are a form of _____________ time polymorphism and overridden methods are form of __________- time polymorphism.


compile, run

run, Compile


14.The statement that calls the constructor of the superclass should be the last statement in the constructor of a subclass.


True

False



15.The capacity of the string buffer can be changed with the ___________ method provided in the class.


Capacity()

ensureCapacity()



16._______________ modifier reduces the amount of data being serialized and improves performance.


Transient

Volatile

Native



17.An assertion can be placed at any location where control will not be reached.


True

False



18.An assert statement checks a Boolean expression during runtime execution.


True

False



19.Requesting for missing files is a common example of ________________ exception.


Checked

Unchecked

Logical

Default



20.A single method can throw only one exception.


True

False



21.___________________ modifier allows the content of a variable to be synchronized across all running threads and ___________________ modifier can be applied only to methods of a class and indicates that the implementation of the method is outside the class.


Native, Transient

Transient, native

Volatile, Transient
Transient, Volatile
Volatile, Native







22.AssertionError contains a default constructor and _________ single-parameter constructors.


8

7

6

9



23.Which of the following statements are true regarding Assertion?


A. An assertion tells the user of the program that something went wrong.
B. An assertion documents some assumption about the program.
C. When an assertion fails, it points out a bug in the programming logic.
D. Assertions are created to deal with problems that might occur during the course of execution of the program.
E. Assertions are written to state assumptions made by the program.

A, B, E

B, C, E

A, C

C, D, E

A, B, C, D


24.Identify the correct answer.

Statement 1: Class variables are initialized only when the class is instantiated.
Statement 2: Instance variables are assigned a default value even before the class is instantiated.

Statement 1 is True, Statement 2 is False.
Statement 1 is False, Statement 2 is True.
Both the statements are True.

Both the statements are False.



25.Which of the following are not the disadvantages of static methods?


Static method can be invoked by using the class name directly.

Static methods can be used to implement behaviors that are not influenced by the state of any instances.
A static method cannot be overridden, although it can be hidden.

Non-static attributes of the class cannot be accessed from within a static method.



26.Which of the following are the advantages of Instance methods?


Instance methods can be overridden and overloaded.

They can be accessed by using an instance of the class using the dot operator.
Static variables cannot be accessed from the instance methods.

Methods having private access in a class are not inherited.



27.Which of the following statements are not true with respect to the finalize method?


Is used to clean external resources such as files and streams that are open.

Garbage collector need not call the finalize method before it collects an instance of an object.
None of the above statements is applicable.



28.Which of the following statements are true about static method?


Static methods state that the method can be called without an object.
Static methods can use only static data and methods.

Static methods cannot be inherited or overridden.



29.Which of the following statements are not true regarding synchronized method modifier?


It is used with a method while implementing threads.

It permits only one thread access to a block of code at a time.

It permits only two thread access to a block of code at a time

It permits any number of thread access to a block of code at a time.



Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4397
    
    8

Hi Santanu. Welcome to the Ranch!

What do you think the answers are? We don't just hand out answers on this site - we're more interested in helping people learn for themselves. A lot of those questions can be answered by reading the documentation, so I'd suggest you start there.

If you don't understand why the answers are what they are, that's where we can help out.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14192
    
  20

Welcome to CodeRanch!

Most of the questions you ask can be answered by studying the Java API documentation. Please look at that documentation and try to answer the questions yourself. If you have more specific questions, please ask them here.

Also, please QuoteYourSources. These questions look like they have been copied from a book or somewhere else. Please tell us where you copied them from.

Santanu kumar Acharya wrote:1.Which of the following methods is not defined in the java.util.Vector class?

Look at the API documentation of class java.util.Vector.
Santanu kumar Acharya wrote:2.Which of the following methods is used while passing or returning a java object from the native method?

Lookup these methods in the API documentation of class java.lang.System.
Santanu kumar Acharya wrote:3.Which of the following exceptions is not a checked exception?

Do you know what a checked exception is? Lookup the API documentation for each of these exception classes.
Santanu kumar Acharya wrote:4.Which of the following is a valid constructor for the DataInputStream class?

Lookup the API documentation of class DataInputStream.

Etc.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Naishadh Parmar
Ranch Hand

Joined: Jun 02, 2011
Posts: 95


Hey Santanu,
Please answer these questions

1) Are you taking our test?

Yes

No

2) Do you have a problem in your application?

Yes

No

3) If the answer to the above question is yes than what is the problem???
Pritam Chatterjee
Ranch Hand

Joined: Jul 31, 2011
Posts: 31

All these questions are from basics. So just go through a standard material for each of the topic then you can find the answers.


Pritam
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39044
    
  23
Since this is an old thread, I cannot see any point in any more answers. Shame the the original poster didn't give any suggestions about the answers when it first came up.
 
GeeCON Prague 2014
 
subject: Please Answer these Questions of java.