Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CS2023-AJP UNIT-1 PART-A UNIT I JAVA FUNDAMENTALS Java I/O streaming – filter and pipe streams – Byte Code interpretation - Threading – Swing. Important Two Marks Q & A 1. What are Byte streams? Byte streams provide a convenient means for handling input and output of bytes. Byte streams are used for example when reading or writing binary data 2. How does pipe differ from filter Stream? [May / June 2011 ] PipedInputStream and PipedOutputStream Classes implements Input and Output Components Of a Pipe. Pipes are used to channel the output from one program (or thread) into the input of another FilterInputStream and FilterOutputStream Classes Implements Filter Streams , Filter used to modify data read from an underlying stream 3. What is a java Bytecode? [May / June 2012 ] Java bytecode is the form of instructions that java virtual machine executes ,Each bytecode opcode is one byte in length 4. Write any four advantages of swing components [May / June 2011 ] Swing components are lightweight It provides Java programmers many new powerful components Swing provides built-in double buffering Swing provides paint debugging support for when you build your own components 5. What is Multithreading? List out the stages involved in thread life cycle [Nov/Dec 2012 ] Multithreading is a process of executing multiple threads simultaneously. Thread is basically a lightweight subprocess, a smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking. Thread Stages: New Stage Runnable Running State Dead State Blocked 6. List out Filter Stream classes BufferedInputStream,BufferedOutputStream DataInputStream,DataOutputStream PrintStream PushbackInputStream GZIPInputStream,GZIPOutputStream DigestInputStream, DigestOutputStream ChiperInputSTream, ChiperOutputSTream L. Maria Michael Visuwasam, A.P, CSE, VIT Page 1 CS2023-AJP UNIT-1 PART-A ObjectInputStream, ObjectOutputStream 7. Write a java code to copy characters from a file to another file [Nov / Dec 2011 ] import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class CopyFile2File { public static void main(String[] args) { String str = "Hi this is data to copy from one file to another file..."; try{ FileOutputStream fos = new FileOutputStream("hello2.dat"); byte b[] = str.getBytes(); fos.write(b); fos.close(); System.out.println("The file hello2 is created with string data"); FileInputStream fis = new FileInputStream("hello2.dat"); System.out.println("Read the data from hello2.dat"); fos = new FileOutputStream("temp.dat"); String str1= ""; int size = fis.available(); int ch; System.out.println("Size of file :"+size); while((ch=fis.read())!= -1){ str1 = str1+(char)ch; } byte b1[] = str1.getBytes(); fos.write(b1); fos.close(); fis.close(); System.out.println("the data of hello2.dat copied to temp.dat"); }catch(IOException ioe){ ioe.printStackTrace(); } } } 8. Define JVM [ May /June 2012 ] A Java virtual machine (JVM) is a virtual machine that can execute Java bytecode. It is the code execution component of the Java platform. A Java virtual machine (JVM), an implementation of the Java Virtual Machine Specification, interprets compiled Java binary code for a computer's processor 9. List out two main Stream classes and two sub classes in each stream Used in Java ? [Nov/Dec 2012 ] L. Maria Michael Visuwasam, A.P, CSE, VIT Page 2 CS2023-AJP UNIT-1 PART-A 10.Give the syntax and use of any four classes in swing? [Nov/Dec 2007 ] JTextField allows editing of a single line of text. New features include the ability to justify the text left, right, or center, and to set the text’s font. JPasswordField (a direct subclass of JTextField) you can suppress the display of input. Each character entered can be replaced by an echo character. JCheckBox is not a member of a checkbox group. A checkbox can be selected and deselected, and it also displays its current state. JComboBox is like a drop down box. You can click a drop-down arrow and select an option from a list. 11.What are the benefits in using swings compared to awt? Swing provide both additional components and added functionality to AWT – replacement Components Swing Components are lightweight Swing provides built-in double buffering Swing provide paint debugging support for when you build your own components L. Maria Michael Visuwasam, A.P, CSE, VIT Page 3