+ All Categories
Home > Documents > OOPJ Papers - Java

OOPJ Papers - Java

Date post: 17-Aug-2015
Category:
Upload: rjk1984
View: 294 times
Download: 21 times
Share this document with a friend
Description:
Java GTU Papers
Popular Tags:
18
1 Seat No.: ________ Enrolment No.___________ GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER– V EXAMINATION – SUMMER 2015 Subject Code: 150704 Date: 07/05/2015 Subject Name: Object Oriented Programming With Java Time:02.30pm-05.00pm Total Marks: 70 Instructions: 1. Attempt all questions. 2. Make suitable assumptions wherever necessary. 3. Figures to the right indicate full marks. Q.1 (a) List various features of Java? Also explain any two feature with example. 07 (b) Compare Object oriented programming with sequential programming. 07 Q.2 (a) What is visibility modifier? Explain all with example. 07 (b) What is package? List various built in package used in java. 07 OR (b) What is Thread? Draw and explain life cycle of thread. 07 Q.3 (a) Write a program which shows an example of function overloading? 07 (b) What is error? Explain various types of errors. How can we handle run time errors in java? 07 OR Q.3 (a) Write a program which shows an example of function overriding? 07 (b) Compare String with StringBuffer class. 07 Q.4 (a) What is variable? How can we define variable in java? Also list rules for valid variable names. 07 (b) What is constructor? What are the rules for creating constructor in java? 07 OR Q.4 (a) Explain inheritance with its types and example. 07 (b) How interface are useful in java? Explain with example. 07 Q.5 (a) What are final class, final function and final variable in java? Explain with example. 07 (b) Explain following key words: this, super, instance of 07 OR Q.5 (a) Compare Java Applets with application programs. 07 (b) How can we open and read a text file in java? Explain your answer with example. 07 *************
Transcript

1 Seat No.: ________ Enrolment No.___________ GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTER V EXAMINATION SUMMER 2015 Subject Code: 150704 Date: 07/05/2015Subject Name: Object Oriented Programming With Java Time: 02.30pm-05.00pm Total Marks: 70 Instructions: 1.Attempt all questions.2.Make suitable assumptions wherever necessary. 3.Figures to the right indicate full marks. Q.1(a)List various features of Java? Also explain any two feature with example.07 (b)Compare Object oriented programming with sequential programming.07 Q.2(a)What is visibility modifier? Explain all with example.07 (b)What is package? List various built in package used in java.07 OR (b)What is Thread? Draw and explain life cycle of thread.07 Q.3(a)Write a program which shows an example of function overloading?07 (b)What is error? Explain various types of errors. How can we handle run time errors in java? 07 OR Q.3(a)Write a program which shows an example of function overriding?07 (b)Compare String with StringBuffer class.07 Q.4(a)What is variable? How can we define variable in java? Also list rules for valid variable names. 07 (b)What is constructor? What are the rules for creating constructor in java?07 OR Q.4(a)Explain inheritance with its types and example.07 (b)How interface are useful in java? Explain with example.07 Q.5(a)Whatarefinalclass,finalfunctionandfinalvariableinjava?Explainwith example. 07 (b)Explain following key words: this, super, instance of07 OR Q.5(a)Compare Java Applets with application programs.07 (b)Howcanweopenandreadatextfileinjava?Explainyouranswerwith example. 07 ************* 1 Seat No.: ________Enrolment No.___________ GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTERV EXAMINATION WINTER 2014 Subject Code: 150704Date:01-12-2014Subject Name: Object Oriented Programming with Java Time: 10.30 am - 01.00 pmTotal Marks: 70 Instructions: 1.Attempt all questions.2.Make suitable assumptions wherever necessary. 3.Figures to the right indicate full marks. Q.1(a)Describe the following features of java: 1)Multithreaded,2)Architecture-neutral3)Interpreted 4)High performance5) Distributed 6) Portable 7) Dynamic 07 (b)DifferentiatebetweenMethodoverloadingandmethodoverridingwith example. 07 Q.2(a)Explain the followings with example Dynamic Method Dispatch , this, super, final 07 (b)Writeaprogramtodemonstratethemultipathinheritancefortheclasseshaving relations as shown in figure 1. Figure 1 07 OR (b)Writeaprogramthatillustratesinterfaceinheritance.InterfaceAisextended byA1andA2.InterfaceA12inheritsfrombothP1andP2.Eachinterface declaresoneconstantandonemethod.ClassBimplementsA12.InstantiateB and invoke each of its methods. Each method displays one of the constants 07 Q.3(a)What are the benefits of using generic types? 03 (b)Differentiate between abstract class and interface.04 (c)Discuss public, private, protected and default access modifier with example.07 OR Q.3(a)What is collection in Java? Differentiate between Vector and Array List. 07 (b)Justify statement. (i)JVM is platform dependent.(ii)There is no destructor in Java. 07 2 Q.4(a)Write a simple GUI application that traces the users action suchKeyboard action. 07 (b)Write a program to replace all word1 by word2 from a file1, and output is written to file2 file and display the no. of replacement. 07 OR Q.4(a)CreateanappletwhichhasaTextFieldtoacceptaURLstring,anddisplays the document of the URL string in a new browser window.07 (b)DifferentiateStringclassandStringBufferclasswithexplanationofits methods. 07 Q.5(a)Write a program to create two threads, one thread will print odd numbers andsecond thread will print even numbers between 1 to 20 numbers.07 (b)Writeaprogramthatcountsnumberofcharacters,words,andlinesinafile. Use exceptions to check whether the file that is read exists or not.07 OR Q.5(a)Explain the following terms with respect to exception handling.i) try ii) catch iii) throw iv) finally07 (b)What is a thread? Describe the complete life cycle of thread with example.07 ************* 1 Seat No.: ________ Enrolment No.___________ GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTERV EXAMINATION SUMMER 2014 Subject Code: 150704Date:17-06-2014Subject Name: Object Oriented Programming with Java Time: 10.30 am - 01.00 pmTotal Marks: 70 Instructions: 1.Attempt all questions.2.Make suitable assumptions wherever necessary. 3.Figures to the right indicate full marks. Q.1(a)Explain features of JAVA.07 (b)What is constructor? Explain constructor overloading with example.07 Q.2(a)What is Multithreading ? Explain Life Cycle of Thread with example.07 (b)Explain following with example: 1.Super keyword. 2.Final keyword07 OR (b)Explain Following: 1.Garbage Collection 2.Short Circuit Operators. 07 Q.3(a)Explain Dynamic method dispatch with proper example.07 (b)Explain package and interface with Example.07 OR Q.3(a)What is an Exception? Explain Exception handling in JAVA.07 (b)Explain thread Synchronization with join() and isAlive() methods. 07 Q.4(a)Answer Following: 1.Benefits of Generic types. 2.Explain Java Beans. 07 (b)Explain Delegation Event model. Also Explain use of Adapter class.07 OR Q.4(a)Differentiate the following: 1.Text I/O v/s Binary I/O. 2.String class v/s StringBuffer class. 07 (b)Explain life cycle of Applet. Create a simple Applet having a message Hello.07 Q.5(a)Create an applet having a circle which is moving from left to right and reflected back from right to left continuously. 07 (b)Explain Layout Manager.07 OR Q.5(a)Create an applet that having three scroll bars for three colors red, green and blue withminimum0andmaximum255values.Thebackgroundcolorofapplet changes depending on the value of the scroll bar at that time.07 (b)Answer following: 1.Collection in JAVA. 2.Features of Map Interface. 07 ************* 1Seat No.: ________ Enrolment No.___________ GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTERV EXAMINATION WINTER 2013 Subject Code: 150704Date:02-12-2013Subject Name: Object Oriented Programming with Java Time: 10.30 am - 01.00 pmTotal Marks: 70 Instructions: 1.Attempt all questions.2.Make suitable assumptions wherever necessary. 3.Figures to the right indicate full marks. Q.1 (a)List and explain various features of java.07 (b)Explain the words super, static, final and this with the help of example.07 Q.2 (a)Explain constructor and finalizer with the help of example.07 (b)CompareStringwithStringBuffer.Alsowriteaprogramtocountoccurrence of character in a string. 07 OR (b)CompareList,SetandMapinterfaces.AlsocompareArrayList,TreeSetand HashMap classes in java. 07 Q.3 (a) Explain Overloading and Overriding with example. 07 (b)What is Layout? Explain various Layout Managers in java.07 OR Q.3Write a note on (Any two)14 (a)JavaBeans (b)Swing in JAVA (c)Network programming in Java Q.4 (a)Draw and explain lifecycle of Applet.07 (b) Write a program to count the total no. of chars, words, lines, alphabets, digits, white spaces in a given file. 07 OR Q.4 (a)Draw and explain life cycle of thread. Also list and explain various methods of thread. 07 (b) WriteajavaapplicationthathasthreeButtonslabeledRed,Green,Blue&on clickingthebackgroundcolorshouldchangeaccordingly&havealabeldisplaying the color selected. 07 Q.5 (a) WhatisException?GivesomeofBuilt-inexceptionsinjava.Alsogivedifference between throw and throws. 07 (b) Writeanapplicationthatcreatesand starts three threads.Each thread isinstantiated fromthesameclass.Itexecutesaloopwith10iterations.Eachiterationdisplays string "HELLO", sleeps for 300 milliseconds. The application waits for all the threads to complete & displays themessage "Good Bye...". 07 OR Q.5 (a) What is package? Explain steps to create package with example. 07 (b) Write an application that executes two threads. One thread displays "GoodMorning" every1000milliseconds&anotherthreaddisplays"GoodAfternoon"every3000 milliseconds. Create the threads by implementing the Runnableinterface. 07 ************* 1/2 Seat No.: ________ Enrolment No.___________ GUJARAT TECHNOLOGICAL UNIVERSITY BE - SEMESTERV EXAMINATION SUMMER 2013 Subject Code: 150704Date: 20-05-2013Subject Name: Object Oriented Programming with Java Time: 10.30 am - 01.00 pmTotal Marks: 70 Instructions: 1.Attempt all questions.2.Make suitable assumptions wherever necessary. 3.Figures to the right indicate full marks. Q.1 (a)List OOP characteristics and describe inheritance with examples.07 (b)Explain & illustrate by examples use of final, finally and method finalize.07 Q.2 (a)Declare a class called coordinate to represent3 dimensional Cartesian coordinates( x, y and z). Define following methods: -constructor-display, to print values of members -add_coordinates, to add three such coordinate objects to produce a resultant coordinate object. Generate and handle exception if x, y and z coordinates of the result are zero.-main, to show use of above methods. 07 (b)Explain short circuited operators, shift operators and this reference. 07 OR (b)Explainpackages,theiruse,adapterclassesandtheirneeds& applications. Give examples.07 Q.3 (a)Declareaclasscalledbookhavingauthor_nameasprivatedata member.Extendbookclasstohavetwosubclassescalled book_publication & paper_publication. Each of these classes have private member called title. Write a complete programtoshowusageofdynamicmethoddispatch(dynamic polymorphism) to display book or paper publications of given author. Use command line arguments for inputting data. 07 (b)(i)Explain super, instanceof and volatile. (ii) Compare byte streams and character streams.07 OR Q.3 (a)ItisrequiredtocomputeSPI(semesterperformanceindex)ofn studentsofyourcollegefortheirregisteredsubjectsinasemester. Declare a class called student having following data members: id_no,no_of_subjects_registered,subject_code,subject_credits, grade_obtained and spi. -Define constructor and calculate_spi methods.-Define main to instantiate an array for objects of class student to processdataofnstudentstobegivenascommandline arguments.07 (b)(i)J VM is platform dependent. J ustify.(ii) There is no destructor in J ava. Justify. 07 Q.4 (a)Write a complete GUI based program to implement a queue of strings in an applet. Select components and layout of your choice. 07 2/2 Q.4 (b)(i)Illustrate by example generic programming. (ii) Explain interface and its usage.07 OR Q.4 (a)Write a complete programto have a GUI based simple calculator in a frame supporting addition & subtraction. There are buttons for 0 to 9 digits and for arithmetic operations. Select layout of your choice. 07 (b)Explain(i)card layout (ii)utility class Hashtable with example.07 Q.5 (a)Writeacompletemulti-threadedprogramtomeetfollowing requirements: oTwothreadsofsametypearetobeinstantiatedinthemethod main. oEach thread acts as a producer as well as a consumer. oA shared buffer can store only one integer information along with the source & destination of the information at a time. oTheinformationproducedistobeconsumedbyappropriate consumer.oBoth producers produce information for both consumers. oEach thread produces 5 information. 07 (b)Explainlifecycleofanapplet.Alsoillustratehowtoprovide parameters to applet through html. 07 OR Q.5 (a)It is required to add two MxN sized matrices having integer elements to produce a third resultant matrix of size MxN.Writeacompletemulti-threadedprogramtomeetfollowing requirements: - Accept all required arguments from the command line. - Instantiate M threads with id 0 to M -1 respectively, each thread performingadditionofelementsontherowspecifiedbyitsidto produce corresponding row of the resultant matrix. 07 (b)Explain wait, notify, synchronized and native methods.07 ************* 1/2 Seat No.: ________ Enrolment No._________ GUJARAT TECHNOLOGICAL UNIVERSITY BE SEMESTER V EXAMINATION WINTER - 2012 Subject code: 150704Date: 16-01-2013 Subject Name: Object Oriented Programming with Java Time: 02:30 pm to 05:00 pm Total Marks: 70 Instructions: 1.Attempt all questions.2.Make suitable assumptions wherever necessary. 3.Figures to the right indicate full marks. Q.1 (a)Differentiatebetweenconstructorandmethodofclass.Definemethod overloading and its purpose. Write a program to demonstrate the constructor overloading. 07(b)Define polymorphism with its need. Define and explain static and dynamic binding using program. 07 Q.2 (a)Differentiate the followings: i)Applet and Application ii)String class and StringBuffer class iii) Constructor and Method 07 (b)TheTransportinterfacedeclaresadeliver()method.Theabstractclass Animal is the super class of the Tiger, Camel, Deer and Donkey classes. The Transport interface is implemented by the Camel and Donkey classes. Write a test program that initialize an array of four Animal objects. If the object implements the Transport interface, the deliver () method is invoked. 07OR (b)What isthe use following java keywords super, transient, finally, final, static, throw, throws07 Q.3 (a)Explain exception handling in J AVA. Write a program that generates custom exceptionifanyintegervaluegivenfromitscommandlineargumentsis negative. 07(b)Write a program to check that whether the name given from command line is file or not? If it is a file then print the size of file and if it is directory then it should display the name of all files in it. 07OR Q.3 (a)Explain the importance of exception handling in java. Which key words are usedtohandleexceptions?Writeaprogramtoexplaintheuseofthese keywords. 07(b)Write a program that counts the no. of words in a text file. The file name is passed as a command line argument. The program should check whether the fileexistsornot.Thewordsinthefileareseparatedbywhitespace characters. 07 Q.4 (a)i) What do you mean by Event Delegation model in J ava? ii) How the concept of inner classes is used for event handling? 07 (b)Write a complete program to create a frame for providing GUI to implement a stack for storing integer numbers. There are two buttons called PUSH & POP and a text field. Clicking of button PUSH pushes the number entered in the text field onto the stack. The click of button POP pops an element from the stack and displays that in the text field. 07OR 2/2 Q.4 (a)i)Explain the life cycle of an applet ii)How the concept of adapter classes is used in event handling? 07(b)Write an applet that draws four horizontal bars of equal size & of different colorssuchthattheycoverupthewholeappletarea.Theappletshould operate correctly even if it is resized. 07 Q.5 (a)Whatismultithreading?Whyitisrequired?Writeaprogramthatcreates three threads. Make sure that the main thread executes last. 07(b)i) What is collection in J ava?Differentiate between Vector and ArrayList ii)Explain the unique features of Map interface. 07OR Q.5 (a)Whysynchronizationisrequiredinmultithreadedprogramming.Writea programthatusesthreadsynchronizationtoguaranteedataintegrityina multithreaded application. 07(b)i) What are generics and how are they used?ii) Differentiate between Enumeration and Iterator. 07 ************* 1 Seat No.: ________Enrolment No.______________GUJARAT TECHNOLOGICAL UNIVERSITY BE- Vth SEMESTEREXAMINATION MAY/JUNE - 2012 Subject code: 150704 Date: 05/06/2012Subject Name: Object oriented programming with Java Time: 02:30 pm 05:00 pmTotal Marks: 70 Instructions: 1.Attempt all questions.2.Make suitable assumptions wherever necessary. 3.Figures to the right indicate full marks. Q.1 (a)Explain features of JAVA.07 (b)Explain interface in JAVA. How do interfaces support polymorphism?07 Q.2 (a)ExplainExceptionhandlinginJAVA.Writeanapplicationthatgenerates custom exception if any value from its command line arguments is negative. 07 (b)Whysynchronizationisrequiredinmultithreadedprogrammingandhowcanwe implement it in program? 07 OR (b)Explain Thread Life Cycle in detail. Write a code to create Thread in JAVA.07 Q.3 (a) Write a program using BufferedInputStream, FileInputStream, BufferedOutputStream, FileOutputStream to copy Content of one file File1.txtinto another file File2.txt. 07 (b)DescribeabstractclasscalledShapewhichhasthreesubclassessay Triangle,Rectangle,Circle. Define one method area() in the abstract class and override this area() in these three subclasses to calculate for specific object i.e. area()ofTrianglesubclassshouldcalculateareaoftriangleetc.Samefor Rectangle and Circle 07 OR Q.3 (a) Write a program to display the bytes of a file in reverse sequence. Provide the name of the file as a command line argument. (Use RandomAccessFile) 07 (b)Writeaprogramthatillustratesinterfaceinheritance.InterfacePisextendedbyP1 andP2.InterfaceP12inheritsfrombothP1andP2.Eachinterfacedeclaresone constant and one method. class Q implements P12.Instantiate Q and invoke each of its methods. Each method displays one of the constants 07 Q.4 (a)Differentiate Applet and Application.07 (b)DifferentiateStringclassandStringBufferclasswithexplanationofits methods. 07 OR Q.4 (a)WriteanappletthatcontainsthreebuttonsOK,CANCELandHELPandone textfield.ifOKispressedshownonthestatusbar-OKispressedandthetext fieldshouldturnred.WhenCANCELispressed-shownonthestatusbar- CANCELispressedandtextfieldshouldturngreen.WhenHELPispressed- shown on the status bar-HELP is pressed and the text field should turn yellow. 07 (b)Explain Applet life cycle with demo program. 07 Q.5 (a)Explain package in java. List out all packages with short description.07 (b)Differentiate Method Overloading and Method Overriding with example. 07 OR Q.5 (a)ExplainEventHandlinginjavaanddescribemethodsofmouseeventandkey event. 07 (b)Explain Generics in java with demo program.07 ************* 1

Seat No.: _____ Enrolment No.______ GUJARAT TECHNOLOGICALUNIVERSITY B. E. Vth SemesterExamination Nov-Dec- 2011 Subject code: 150704 Subject Name: Object Oriented Programming with Java Date:29/11/2011Time: 02:30 pm 05:30 pm Total Marks: 70 Instructions: 1.Attempt all questions.2.Make suitable assumptions wherever necessary. 3.Figures to the right indicate full marks. Q.1 (a)Differentiatethe followings: (i) Checked and Unchecked Exceptions (ii)Constructor and method (iii) Text I/O and Binary I/O 06 (b)Explain the followings: (i)Dynamic Method Dispatch with example (ii) this, super, final 06 (c)What are the benefits of using generic types?02 Q.2 (a)Answer the following questions:07 (i) Which methods are called by an applet viewer or browser during the lifetime of an applet? When are they invoked? (ii)Explain interprocess communication mechanism (wait(), notify() and notifyall()) being used by java to avoid polling. (b)Design a class named Fan to represent a fan. The class contains: - Three constants named SLOW, MEDIUM and FAST with values 1,2 and 3 to denote the fan speed.-Anintdatafieldnamedspeedthatspecifiesthespeedofthefan(default SLOW).-Abooleandatafieldnamedf_onthatspecifieswhetherthefanison(default false).-Adoubledatafieldnamedradiusthatspecifiestheradiusofthefan(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, thedisplay()methoddisplaysspeed,colorandradius.Ifthefanisnoton,the method returns fan color and radius along with the message fan is off.Writea test program that creates two Fan objects. One with default values and theotherwithmediumspeed,radius6, color brown, and turned on status true. Display the descriptions for two created Fan objects. 07 OR (b)Define the Rectangle class that contains:Two double fields x and y that specify the center of the rectangle, the data field width and height ,A no-arg constructor that creates the default rectangle with (0,0) for (x,y) and 1 for both width and height. 07 2 Aparameterizedconstructorcreatesarectanglewiththespecifiedx,y,height and width.A method getArea() that returns the area of the rectangle.A method getPerimeter() that returns the perimeter of the rectangle.Amethodcontains(doublex,doubley)thatreturnstrueifthespecifiedpoint (x,y) is inside this rectangle.Write a test program that creates two rectangle objects. One with default values andotherwithuser specified values. Test all the methods of the class for both the objects. Q.3 (a)Answer the following questions:07 (i)Explain the life cycle of a thread. (ii) Explain Java garbage collection mechanism.(b)State whether the following statements are true or false: (i)The elements in an array must be of primitive data types. (ii)When invoking a constructor from a subclass, its super classs no-arg constructor is always invoked.(iii) A protected data or method can be accessed by any class in the same package.(iv) A method can change the length of an array passed as a parameter. 04 (c)State whether any error exists in the following code. If so, correct the error and give output. 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); } } 03 OR Q.3 (a)Answer the following questions:07 (i) Name three types of layout managers and briefly explain their operations. (ii) What is an event source? What are the three responsibilities of event sources? (b)State whether the following statements are true or false: (i)An abstract class contains constructors.(ii) The catch block is the preferred means for releasing resources to prevent resource leaks.(iii) Ifcapacity 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.04 3 (c)Give output of the following program: public class Test { public static void main(String args[]){ Count myCount = new Count(); int times=0; for(int i=0;iD

Figure 1 OR (b)Writeaprogramtodemonstratethemultipathinheritancefortheclasses having relations as shown in figure 2. 07 A->(B,C)->D Figure 2 Q.3 (a)Definegenericsinjava.Writeaprogramtodemonstrategenericinterface and generic method. 07 (b)Define andwritea program to differentiate between pass by valueand pass by reference. 07 OR AB C D D A BC D 2 Q.3 (a)Definegenericsinjava.Writeaprogramtodemonstrategenericclassand generic constructor. 07 (b)Differentiatebetweenabstractclassandinterfacespecifyingmatricesof differences.Writeaprogramtodefineabstractclass,withtwomethods addition()andsubtraction().addition()isabstractmethod.Implementthe abstract method and call that method using a program(s). 07 Q.4 (a)Writeaneventhandlingprogramtohandlee-mailsendingformusingyour creativity.07 (b)Write a program to replace all word1 by word2 from a file1, and output is written to file2 file and display the no. of replacement. 07 OR Q.4 (a)WriteaneventhandlingprogramtohandlefeedbackformofGTU examination system using your creativity. 07 (b)Writeaprogramtoreplaceallword1byword2toafilewithoutusing temporary file and display the no. of replacement. 07 Q.5 (a)ExplaintheimportanceofExceptionhandlinginjava.Writeaprogramto handleNoSuchMethodException,ArrayIndexOutofBoundsExceptionusing try-catch-finally and throw. 07 (b)Write a program of writing binary file using multithreading. Demonstrate use of join() and yield() interrupt(). 07 OR Q.5 (a)Enlistandexplainthedifferencebetweenerrorandexception.Writea programtohandleInterruptedException,IllegalArgumentExceptionusing try-cat-finally and throw. 07 (b) Writeaprogramtoadd(keyword,URL)listforawebcrawlerinsuitable data structure in concurrent manner but one process at a time, and retrieving data from the data structure in concurrent manner. 07 *************


Recommended