ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Name the class that used to read objects directly from a 
stream?
 Question Submitted By :: Nimitha
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Name the class that used to read objects directly from a stream?
Answer
# 1
ObjectInputStream
 
Is This Answer Correct ?    1 Yes 0 No
Prasad
 
  Re: Name the class that used to read objects directly from a stream?
Answer
# 2
Hi... ObjectOutPutSteam and ObjectInputStream are used for 
readign and writing.
 
Is This Answer Correct ?    0 Yes 3 No
Devarathnam
 
 
 
  Re: Name the class that used to read objects directly from a stream?
Answer
# 3
Ans 2 
is wrong in fact its apposite is true

i.e. 
for reading ObjectInputStream

for writing ObjectOutputStream
 
Is This Answer Correct ?    2 Yes 0 No
Ravi Jian
 
  Re: Name the class that used to read objects directly from a stream?
Answer
# 4
ObjectInputStream ObjectOutPutSteam are used for readign and
writing.

Here is a simple example:

import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 *
 * @author javadb.com
 */
public class Main {
    
    /**
     * Example method for using the ObjectInputStream class
     */
    public void readPersons(String filename) {
        
        ObjectInputStream inputStream = null;
        
        try {
            
            //Construct the ObjectInputStream object
            inputStream = new ObjectInputStream(new
FileInputStream(filename));
            
            Object obj = null;
            
            while ((obj = inputStream.readObject()) != null) {
                
                if (obj instanceof Person) {
                
                    System.out.println(((Person)obj).toString());
                }
                
            }
            
         
        } catch (EOFException ex) { //This exception will be
caught when EOF is reached
            System.out.println("End of file reached.");
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            //Close the ObjectInputStream
            try {
                if (inputStream != null) {
                    inputStream.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new Main().readPersons("myFile.txt");
    }
}
 
Is This Answer Correct ?    0 Yes 0 No
Qim2010
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
IN java collections we have both interfaces and classes. instead of using interfaces why we can't use classes only like that why we can't use interfaces only. why we need two things interface and class. CTS4
How many bits are allocated to represent character of character sets - Unicode, ASCII, UTF-16, UTF-8?  1
What is Collection interface? Zensar1
What is Runtime class and its purpose?  2
what is Dictionary? and what purpose it is used for?  2
Explain Public static void main? IBM2
What advantage does an entity bean have over a sessin bean? Adobe3
Hi buddy, well i got that there is always a default constructor with abstract class. OK. But why not with interface? Thanks in advance.  2
How to validate the request (Eg:user name and password) in session(http session)? not in LDAP server ? Saksoft1
What JNDI(Java Naming and Directory Interface) provides?  4
What error occurs if a try-catch-finally statement sequence does not have a catch clause?  2
What is the USE of Null interfaces ??...if thers nothing inside these interfaces how are they used and WHy are they used ???? No 1 has given a proper description yet  1
What is persistence ?  2
What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ? We can write our own functionality which writes objects to streams then why we need to implement and tell JVM that which objects can be serialized. iFlex4
Explain final, finalize() and finally? Accenture9
What is the range of the char type?  3
if i have one string class then how can you achive this class functionality of this class? Fidelity3
How can we handle runtime exceptions? write one sample program? Can we write runtime exceptions beside the throws key word? if yes write sample program? Huawei1
what is meant by serialization?  6
What is thin driver and thick driver. why it is called so? Logisoft1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2009  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com