Welcome To Computer Branch! - Home



ShankerSinh Vaghela Bapu Institute Of TechnologyB.E. Semester V (CE)Object Oriented Programming with Java Question BankUnit-11.Explain features of JAVA.June-122.Ragged ArrayNov-113.Explain short circuited operators and shift operators.June-114.Expalin public static void main. In detail.Unit-21.Differentiate String class and StringBuffer class with explanation of its methods.June-122.Differentiate the followings: (i) Constructor and methodNov-113.Explain the followings: (i) this, super, finalNov-114.Design a class named Fan to represent a fan. The class contains:Nov-11- Three constants named SLOW, MEDIUM and FAST with values 1,2 and 3 to denote the fanspeed.- An int data field named speed that specifies the speed of the fan (default SLOW).- A boolean data field named f_on that specifies whether the fan is on(default false).- A double data field named radius that specifies the radius of the fan (default 4).- A data field named color that specifies the color of the fan (default blue).- A no-arg constructor that creates a default fan.- A parameterized constructor initializes the fan objects to given values.- A method named display() will display description for the fan. If the fan is on, the display()method displays speed, color and radius. If the fan is not on, the method returns fan color andradius along with the message “fan is off”. Write a test program that creates two Fan objects.One with default values and the other with medium speed, radius 6, color brown, and turnedon status true.Display the descriptions for two created Fan objects5.Define the Rectangle class that contains:Nov-11Two double fields x and y that specify the center of the rectangle, the data field width andheight , A no-arg constructor that creates the default rectangle with (0,0) for (x,y) and1 forboth width and height. 2 A parameterized constructor creates a rectangle with the specifiedx,y,height and width.A method getArea() that returns the area of the rectangle.A method getPerimeter() that returns the perimeter of the rectangle.A method contains(double x, double y) that returns true if the specified point (x,y) is inside thisrectangle.Write a test program that creates two rectangle objects. One with default values and otherwith user specified values. Test all the methods of the class for both the objects.6.Explain Java garbage collection mechanism.Nov-117.What is an inner class?Nov-118.The abstract Vegetable class has three subclasses named Potato, Brinjal andNov-11Tomato. Write an application that demonstrates how to establish this classhierarchy. Declare one instance variable of type String that indicates the color ofa vegetable. Create and display instances of these objects. Override the1toString() method of Object to return a string with the name of the vegetableand its color.9.Explain this reference, key word static and garbage collection.June-1110.Differentiate between constructor and method of class. Define method overloading and itsDec-10purpose. Write a program to demonstrate the constructor overloading.11.Define and write a program to differentiate between pass by value and pass by reference.Dec-10Unit-31.Explain interface in JAVA. How do interfaces support polymorphism?June-122.Describe abstract class called Shape which has three subclasses sayJune-12Triangle,Rectangle,Circle. Define one method area() in the abstract class and override thisarea() in these three subclasses to calculate for specific object i.e. area() of Triangle subclassshould calculate area of triangle etc. Same for Rectangle and Circle3.Write a program that illustrates interface inheritance. Interface P is extended by P1June-12and P2. Interface P12 inherits from both P1 and P2.Each interface declares one constant andone method. class Q implements P12.Instantiate Q and invoke each of its methods. Eachmethod displays one of the constants4.Explain package in java. List out all packages with short description.June-125.Differentiate Method Overloading and Method Overriding with example.June-126.Explain Generics in java with demo program.June-127.Explain the followings:Nov-11(i) Dynamic Method Dispatch with example8.What are the benefits of using generic types?Nov-119.Explain Cosmic superclass and its methods.Nov-1110.The Transport interface declares a deliver() method. The abstract class Animal is theNov-11superclass of the Tiger, Camel, Deer and Donkey classes. The Transport interface isimplemented by the Camel and Donkey classes. Write a test program that initialize an arrayof four Animal objects. If the object implements the Transport interface, the eliver() method isinvoked.11.Explain final and super by giving examples.June-1112.Declare a class called employee having employee_id and employee_name as members.June-11Extend class employee to have a subclass called salary having designation andmonthly_salary as members. Define following:- Required constructors- A method to find and display all details of employees drawing salary more than Rs. 20000/-.- Method main for creating an array for storing these details given as command linearguments and showing usage of above methods.13.Explain method overriding and method overloading with the help of examples.June-1114.Explain package and interface by giving examples.June-1115.Explain inner class and working of concatenation operator + by giving examples.June-1116.Define polymorphism with its need. Define and explain static and dynamic binding usingDec-10program.17.Explain single level and multiple inheritances in java. Write aDec-10program to demonstrate combination of both types of inheritanceas shown in figure 1. i.e.hybrid inheritance519430-1550670218.Write a program to demonstrate the multipath inheritance for Dec-10the classes having relations as shown in figure 2A->(B,C)->D519430-43116519.Define generics in java. Write a program to demonstrate generic interfaceDec-10and generic method.20.Define generics in java. Write a program to demonstrate generic class andDec-10generic constructor.21.Differentiate between abstract class and interface specifying matrices ofDec-10differences. Write a program to define abstract class, with two methodsaddition() and subtraction(). addition() is abstract method. Implement theabstract method and call that method using a program(s).Unit-41.Differentiate Applet and ApplicationJune-122.Write an applet that contains three buttons OK,CANCEL and HELP and one textfield. if OK isJune-12pressed shown on the status bar-“OK is pressed” and the text field should turn red. WhenCANCEL is pressed -shown on the status bar-“ CANCEL is pressed “and text field should turngreen. When HELP is pressedshown on the status bar-“HELP is pressed” and the text fieldshould turn yellow3.Explain Applet life cycle with demo program.June-124.Explain Event Handling in java and describe methods of mouse event and key event.June-125.Which methods are called by an applet viewer or browser during the lifetime of an applet?Nov-11When are they invoked?6.Name three types of layout managers and briefly explain their operations.Nov-117.What is an event source? What are the three responsibilities of event sources?Nov-118.Differentiate Application and AppletNov-119.Write an applet that draws four horizontal bars of equal size & of different colors such thatNov-11they cover up the whole applet area. The applet should operate correctly even if it is resized.10.Write an applet that tracks the position of the mouse when it is dragged or moved. At theNov-11current mouse position, it displays message (x, y) showing current position of the mouse. Themessage should disappear as soon as the user releases the mouse.11.Explain various methods called during execution cycle of the applet. Also explain boarderJune-11layout.12.Write a program to create a frame with exit capabilities. Handle events for mouse pressed,June-11mouse released, mouse clicked and mouse dragged by displaying appropriate messagedescribing the event at the coordinates where the event has taken place.13.Explain event handling and different event types of Java.June-1114.Write a complete program to create a frame for providing GUI to implementa stack for storingJune-11integer numbers. There are two buttons called PUSH & POP and a text field. Clicking ofbutton PUSH pushes the number entered in the text field onto the stack. The click of buttonPOP pops an element from the stack and displays that in the text field.15.Write an event handling program to handle e-mail sending form using your creativity.Dec-1016.Write an event handling program to handle feedback form of GTU examination system usingDec-10your creativity.3Unit-51.Write a program using BufferedInputStream, FileInputStream, BufferedOutputStream,June-12FileOutputStream to copy Content of one file File1.txt into another file File2.txt.2.Write a program to display the bytes of a file in reverse sequence. Provide the name ofJune-12the file as a command line argument. (Use RandomAccessFile)3.Differentiate the followings:Nov-11Text I/O and Binary I/O4.Write a program that takes input for filename and search word from commandline argumentsNov-11and checks whether that file exists or not. If exists, the program will display those lines from afile that contains given search word.5.Write a program that counts the no. of words in a text file. The file name is passed as aNov-11command line argument. The program should check whether the file exists or not. The wordsin the file are separated by white space characters.6.Explain File constructors, any two methods of class File and method seek.June-117.Write a program to replace all “word1” by “word2” f rom a file1, and output is written to file2 fileDec-10and display the no. of replacement8.Write a program to replace all “word1” by “word2” t o a file without using temporary file andDec-10display the no. of replacement.Unit-61.Explain Exception handling in JAVA. Write an application that generates custom exception ifJune-12any value from its command line arguments is negative.2.Why synchronization is required in multithreaded programming and how can we implement itJune-12in program?3.Explain Thread Life Cycle in detail. Write a code to create Thread in JAVA.June-124.Differentiate the followings:Nov-11(i) Checked and Unchecked Exceptions5.Explain interprocess communication mechanism (wait(), notify() and notifyall()) being used byNov-11java to avoid polling6.Explain the life cycle of a thread.Nov-117.Describe the Java Collections Framework. List the interfaces, abstract classes and concreteNov-11classes of collection hierarchy.8.Write a method for computing xy by doing repetitive multiplication. x and y are of type integerJune-11and are to be given as command line arguments. Raise and handle exception(s) for invalidvalues of x and y. Also define method main. Use finally in above program and explain itsusage9.Explain: wait, sleep and synchronizeJune-1110.Write a complete multi-threaded program to meet following requirements:June-11- Read matrix [A] m x n- Create m number of threads- Each thread computes summation of elements of one row, i.e. i th row of the matrix isprocessed by i th thread. Where 0 <= i < m.- Print the results.11.It is required to have total two threads, both capable of acting as a produce as well as aJune-11consumer. If first thread acts as a producer then, the second thread becomes the consumerand vice-versa. They communicate with each other through a buffer, storing one integernumber. One of the threads initiates the communication by sending 1 to the other thread. Thesecond thread, on receiving 1 sends 2 to the first thread. On receiving 2, the first threadsends three integer numbers, one by one to the second thread. The second thread consumesthe numbers by displaying them. Both threads terminate after that. Note that both threadsmust be capable of initiating the communication. Write complete multi-threaded program tomeet above requirements.12.Explain utility class Hashtable and instanceof operator by giving examples.June-1113.Write a program to create directories (/home/abc/bcd/def/ghi/jkl) in the home directoryDec-10/home/abc and list the files and directories showing file/directory, file size. Read-write-execute4permissions. Write destructor to destroy the data of a class.14.Explain the importance of Exception handling in java. Write a program to handleDec-10NoSuchMethodException, ArrayIndexOutofBoundsException using try-catch-finally and throw.15.Write a program of writing binary file using multithreading. Demonstrate use of join() andDec-10yield() interrupt().16.Enlist and explain the difference between error and exception. Write a program to handleDec-10InterruptedException, IllegalArgumentException using try-cat-finally and throw17.Write a program to add (keyword, URL) list for a web crawler in suitable data structure inDec-10concurrent manner but one process at a time, and retrieving data from the data structure inconcurrent manner.State whether the following statements are true or false: (Nov-11)The elements in an array must be of primitive data types. When invoking a constructor from a subclass, its super class’s no-arg constructor is always invoked. A protected data or method can be accessed by any class in the same package. A method can change the length of an array passed as a parameter. State whether the following statements are true or false: (Nov-11)An abstract class contains constructors. The catch block is the preferred means for releasing resources to prevent resource leaks. If capacity increment is not specified for Vector, the system will double the size of Vector each time additional capacity is needed. (iv)An interface can extend an abstract class. State whether any error exists in the following code. If so, correct the error and give output. (Nov-11)class Test {public static void main(String args[]) { A a = new A();a.print();}}class A { String s;A(String s) { this.s=s;}public void print() { System.out.println(s);}}5Give output of the following program: (Nov-11) public class Test {public static void main(String args[]) { Count myCount = new Count(); int times=0;for(int i=0;i<100;i++) increment(myCount,times); System.out.println("count is "+myCount.count); System.out.println("times is "+times);}public static void increment(Count c,int times) { c.count++;times++;}}class Count {public int count; Count(int c){ count=c; } Count(){ count=1; }}Give output of the following program for value of y=0 and y=2: (Nov-11) public class Test {public static void main(String args[]) { try {System.out.println("calling method a"); a();System.out.println("return from method a");} catch(ArithmeticException e) { System.out.println("main: catch"); } finally { System.out.println("main: finally"); } }public static void a() { try {int x=8,y=0; int z=x/y;System.out.println("value of z="+z);} catch(NumberFormatException e) { System.out.println("method a:catch"); } finally { System.out.println("method a:finally");}}}6 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download