Important Questions for Java Gtu | Imp For Java Gtu | Java Gtu | How to pass Java Exam.

Important Questions of JAVA




Chapter 1:- Basics of Java.

  • Explain features of Java. (7 Mark)
  • Compare Object oriented programming with sequential programming. (3 Mark)
  • Define following.
    1. Byte code
    2. Java Virtual Machine
    3. Unicode

Chapter 2:- Array and String.

  • State difference between String Class and StringBuffer Class. (3 Mark)
  • Write a program that creates and initializes a four integer element array. Calculate and display the average of its values. (7 Mark)
  • Compare String and StringBuffer. Declare a class called Book having book title and author name as members. Create a sub-class of it, called BookDetails having price & current stock of book as members. Create an array for storing details of n books. Define methods to achieve following - Initialization of members - To query availability of a book by author name / book title- To update stock of a book on purchase and sell .Define method main to show usage of above methods. (7 Mark)
  • Write a complete program to read from console up to n lines or until “quit” is entered. The lines entered are displayed on the screen after reading all lines. The program also counts lines beginning with character 'A' or 'E' as first letter. (7 Mark)
  • Create a class called Student. Write a student manager program to manipulate the student information from files by using the BufferedReader and BufferedWriter. (7 Mark)
  • Create a two dimensional array. Instantiate and Initialize it. (4 Mark)
  • Write a program to find whether the given string is palindrome or not. (3 Mark)
  • Write a program which takes five numbers as command line argument from user, store them in one dimensional array and display count of negative numbers. (4 Mark)

Chapter 3:- Classes, Objects and Methods.

  • Differentiate between Method overloading and Method overriding. (7 Mark)
  • Explain following with example: 1) Finalize. 2) Static. (7 Mark)
  • The abstract vegetable class has three subclasses named Potato, Brinjal and Tomato. Write a java prog. That demonstrates how to establish this class hierarchy. Declare one instance variable of type String that indicates the color of a vegetable. Crete and display instances of these objects. Override the toString() method of object to return a string with the name of vegetable and its color. (7 Mark)
  • Differentiate between constructor and method of a class. (3 Mark)
  • Explain use of Linked List collection class with example. (7 Mark)
  • Explain different Visibility modifiers. (3 Mark)
  • Explain following terms with example: 1) Nested Class and 2) Anonymous Inner Class. (7 Mark)
  • Explain keywords private and protected. (4 Mark)
  • Explain Following terms:- 1) Wrapper Class and 2) Recursion. (4 Mark)
  • Write a program which shows an example of function overriding.(7 Mark)
  • Write a java program to do sum of command line argument passed two Double numbers. (7 Mark)
  • Explain use of Linked List collection class with example. (7 Mark)
  • Write a program to create circle class with area function to find area of circle. (7 Mark)
  • Explain garbage collection and finalize method in JAVA. (7 Mark).
  • Explain constructor overloading using example. (7 Mark)
  • Explain method overriding with example. (7 Mark)
  • It is required to compute SPI (semester performance index) of n students of a class for their registered subjects in a semester. Assume that all students register for 6 subjects and each subject carry 5 credits. Also, follow GTU convention and method for computation of SPI. Declare a class called student having following data members, id_no, grades_obtained and spi. Define constructor, display and calculate_spi methods. Define main to process data of n students. (7 Mark)
  • Explain keywords private and protected. (3 Mark)
  • Define a recursive method for computing x raised to power y by doing repetitive multiplication where x and y are positive integer numbers. Define main to use above method. (4 Mark)
  • Write a method for computing first n terms of Fibonacci sequence. Define method main taking value of n as command line argument and calling the method. (4 Mark)
  • Explain the words ‘static’ and ‘this’ with the help of example. (7 Mark)
  • Write a class named Rectangle to represent a rectangle. It contains following members: (7 Mark)
    Data: width (double) and height (double) that specify the width and height of the rectangle.
    Methods:
    1. A no-arg constructor that creates a default rectangle.
    2. A constructor that creates a rectangle with the specified width and height.
    3. A method named getArea() that returns the area of this rectangle.
    4. A method named getPerimeter() that returns the perimeter.
  • Write an abstract class named Person and its two subclasses named Student and Employee.
    A person has a name, address, phone number, and email address. A student has enrollment, course. An employee has an office, salary, and designation. Define constructors and methods for input and display for both classes. Write a main program to give demonstration of all.



Chapter 4:- Inheritance and Interfaces.

  • Explain following with example: 1) Super. 2) Final. (7 Mark)
  • Describe Inheritance and its type with suitable example. (7 Mark).
  • Explain use of Interface with suitable example. (7 Mark)
  • Differentiate between interface and abstract class. (7 Mark)
  • Explain Interface in JAVA. How do interfaces support polymorphism? (7 Mark)
  • Describe Inheritance and its types with suitable example. (4 Mark)
  • Explain keyword final by giving examples. (4 Mark)
  • Explain interface with help of example(s). (3 Mark).
  • Explain dynamic method dispatch by giving an example. (3 Mark)
  • What do you mean by Interface? Compare interface and abstract class with suitable example. (7 Mark)
  • What do you understand by super keyword? Write use of super keyword. (3 Mark)

Chapter 5:- Package.

  • Explain package and its use with appropriate example. (4 Mark)
  • What is package? What are the requirements of it? What we can achieve using package? (4 Mark)
  • What do you understand by package? Discuss benefits of package. (3 Mark)

Chapter 6:- Exception Handling.

  • Write a method for computing x^y doing repetitive multiplication. X and y are of type integer and are to be given as command line arguments. Raise and handle exception(s) for invalid values of x and y. (7 Mark)
  • Explain use of finally in exception handling. (4 Mark)
  • Differentiate Between Checked and Unchecked exceptions. (4 Mark)
  • With example explain use of finally in exception handling. (7 Mark)
  • Write an application that searches through its command-line argument. If an argument is found that does not begin with and upper case letter, display error message and terminate. (7 Mark).
  • Explain use of throw in exception handling with example. (7 Mark)
  • It is required to maintain and process the status of total 9 resources. The status value is to be stored in an integer array of dimension 3x3. The valid status of a resource can be one of the followings: free: indicated by integer value 0 .occupied: indicated by integer value 1.inaccessible: indicated by integer value
    2.Declare a class called ResourcesStatus, having data member called statusRef, referring to a two dimensional array (3x3) of integers to be used to refer to the above mentioned status values.
    Define a member method called processStausCount that counts and displays total number of free resources, total number of occupied resources and total number of inaccessible resources. The exception to be raised and handled if total number of occupied resources exceeds total number of free resources. The handler marks status of all inaccessible resources as free. Accept initial status values from command line arguments and initialize the array. Raise and handle user defined exception if invalid status value given. (7 Mark)
  • Write a complete program to accept N integer numbers from the command line. Raise and handle exceptions for following cases - when a number is –ve.
    - when a number is evenly divisible by 10.
    - when a number is greater than 1000 and less than 2000
    - when a number greater than 7000 Skip the number if an exception is raised for it, otherwise add it to find total sum.
    (7 Mark)
  • Discuss exception and error. (3 Mark)
  • Explain the importance of exception handling in java. Which keywords are used to handle exceptions? Write a program to explain the use of these keywords. (7 Mark)
  • What is Exception? Demonstrate how you can handle different types of exception separately. (4 Mark)
  • Explain following keywords with example 1) throw 2) throws. (7 Mark)
  • Consider following code fragment: (4 Mark)
    try {
    statement1;
    statement2;
    statement3;
    }
    catch (Exception1 ex1) {
    }
    finally {
    statement4;
    }
    statement5;


    1. Which Statements will execute if no exception is occurs.
    2. Which Statements will execute if Exception 1 is occurs at statement 2.



Chapter 7:- Multithreaded Programming.

  • Explain Thread life cycle and describe creation of thread with suitable example. (7 Mark).
  • Write a program to create two threads, one thread will check whether given number is prime or not and second thread will print prime numbers between 0 to 100. (7 Mark)
  • Explain multi threading in java using example. (7 Mark)
  • Write a multithreaded program to compute and print prime numbers up to n where n is given as command line argument. Instantiate requited number of threads where each thread except the last, examines next 50 numbers and the last thread examines remaining numbers to check whether a number is a prime or not.
  • Write a complete multi threaded program to meet following requirements for producer-consumer threads: - Three threads –one producer and two consumers to be instantiated in the method main.
    - At a time, the producer produces one integer information along with consumer_id to represent id of a consumer that will consume produced information.
    - Information and consumer_id are stored in a shared buffer.
    - The information produced is to be consumed by appropriate consumer only, as specified by the producer.
    - The producer thread produces total 6 information.
    (4 Mark)
  • Draw and Explain Thread Life Cycle. (3 Mark)
  • List and Explain Methods for Inter-thread communication (cooperation). (3 Mark)
  • What is multithreading? What are the ways in which you can create a thread? Explain with Example. (7 Mark)
  • Write a program to create two thread one display alphabet from a to z and other will display numbers from 1 to 100. (4 Mark)

Chapter 8:- IO Programming.

  • Write a program to check whether the name given from command line is file or not? If it is a file then print the size of a file and if it is a directory then it should display the name of all files in it. (7 Mark)
  • Differentiate Between Text I/O and Binary I/O. (4 Mark)
  • Write a program using BufferedInputStream, FileInputStream, BufferedOutputStream, FileOutputStream to copy content of one file Test1.txt into another file Test2.txt. (7 Mark)
  • Write an application that reads a file and counts the number of occurrences of digit 5. Supply the file name as a command-line argument. (7 Mark)
  • Explain usage of class FileInputStream by giving an example. (7 Mark)
  • Explain usage of class FileInputStream and FileOutputStream by giving an example.
  • Write a program that reads file name from user, through command line argument and displays/reads content of the text file on console. (3 Mark)
  • Write a program that counts number of characters, words, and lines in a text file. (7 Mark)

Chapter 9:- Collection Classes.

  • Write a note on %Collection in JAVA'. Also discuss List and Enumeration Interface. (3 Mark)
  • What do you understand by Collection framework in java? List methods available in iterator interface. (3 Mark)



Chapter 10:- Networking with java.net.

  • State difference between DatagramSocket and DatagramPacket. (3 Mark)
  • Explain InetAddress class and its one method. (7 Mark)
  • Write a program that accepts name of website from user, and displays IP address of it on console. (3 Mark)
  • State difference between Socket and ServerSocket. (3 Mark)

Chapter (11-15):- Modeling Part

  • List out the steps of preparing domain class model. What are the criteria for identifying right classes? (7 Mark)
  • What do you mean by an event in state diagram? Discuss various types of events. (7 Mark)
  • Explain various steps required for class design. (7 Mark)
  • Prepare a sequence diagram for issuing book in the library management system. (7 Mark)
  • Explain ‘ordered’, ‘bags’, ‘sequences’ in class diagram with suitable examples. (7 Mark)
  • Explain Nested States. Draw the Nested states diagram for the phone line. (7 Mark)
  • Define the following terms: (7 Mark)
    1. Aggregation,
    2. Abstract Class,
    3. Generalization,
    4. Reification
    5. Constraints,
    6. Package and
    7. Metadata.
    8. Association
    9. Multiplicity
    10. Qualified Association
  • Prepare an activity diagram for Online Bus ticket booking system. (4 Mark)
  • What is Interaction modeling? Explain briefly usage of Use case model. Prepare a Use case model for Telephone Line system. (7 Mark)
  • Draw a state model for Telephone Line system. (4 Mark)
  • Write a sequence diagram of ATM withdrawal process. (4 Mark)
  • Explain Class Model, State model and Interaction model. (7 Mark)
  • Draw class diagram for online restaurant system. (7 Mark)
  • Explain activity diagram with the help of an example. (7 Mark)
  • Prepare a class model to describe undirected graph. An undirected graph consists of a set of vertices and a set of edges. Edges connect pairs of vertices. Your model should capture only structure of graphs (i.e. connectivity) and need not be concerned with layout such as location of vertices or lengths of edges. (4 Mark)
  • Draw class diagram of bank management system. (7 Mark)
  • Draw use case diagram for hotel management system. (7 Mark)
  • Explain generalization in class diagram with example. (4 Mark)
  • What is UML? Explain Class Model, State Model and Interaction Model in brief. (4 Mark)

Related Posts
Important Question of Computer Graphics (2151603)
Important Question for System Programming (2150708)

Post a Comment

5 Comments

  1. Bohot bediya kam kiya he bhai aapne....����

    ReplyDelete
    Replies
    1. Wc bro.... Aeto jruri he hum sab k liye 🤣🤣

      Delete
  2. Ty for this.. It is very helpful to us...��

    ReplyDelete