Download JAVA workbook and questions. and more Exams Java Programming in PDF only on Docsity!
University of Engineering & Management, Kolkata Workbook Paper: Object Oriented Programming using JAVA Paper Code: CS504D
Week 1: Introduction
History of Java, Bytecode, JDK, JVM, JRE, Java features, Data types (Premitive and non premitive),
Operators and its precedence, switch, different loop, method invocation, Arrays
- Why Java is called a purely object-oriented language?
- Why Java is called a strongly typed language?
- What is a literal (constant)? What are the different types of literal supported in Java?
- Differentiate between Boolean & and Short-Circuit && operator.
- What is an array? How does an array in Java differ from an array in C.
- What is a variable? What do you mean by dynamic initialization of variables?
- Why JAVA is called compile-interpreted language?
- What are byte codes? How are they different from machine codes?
- What are typical responsibilities of JVM.
- What is a token? List the various types of tokens supported by Java with brief description.
- Write a program that stores information in the array and then sort the array.
- What do you mean by “Java is a platform independent language but JVM is platform dependent”?
- Explain all words in the statement: “public static void main (String args [ ] )”.
- What might be the difference in functionality between a machine with only JDK installed and another machine with only JRE installed?
- Explain the complete execution procedure of a JAVA source code. Week 2: Class and Object and Properties
Understanding OOPs concepts, defining a Class, Creating Objects, constructors, Other methods, Constructors, Method Overloading, this, object passing and returning
- What is encapsulation?
- What is data hiding?
- Distinguish instance variables and local variables and static variable with special reference to their scope and lifetime.
- What is Object Oriented Programming? How does it overcome the difficulties of a Procedure Oriented Programming?
- Explain the principles of OOP?
- Explain each token in the statement: System.out.println(“Hello Java”);
- State the restrictions that are to be followed by a static method.
- What are the functions of a constructor? What are its special properties?
- How do you call a static method?
- What is constructor overloading?
- Can we use a constructor to reinitialize an object?
- In what order are constructors invoked along the inheritance chain, when a derived class object is created?
Week 3: Class and Object and Properties (Continues)
Static variables and methods, Constructors, Method Overloading, this, object passing and returning
- Can a method be overloaded based on different return type but same argument type?
- What would happen if we try to print an object using System.out.println()?
- What is method overloading? How is a call to an overloaded method resolved?
- Differentiate between a class and an Object? What is the use of „this‟ keyword?
- How many times is a static variable created and when? Give an example.
- How are objects created in Java? What is the use of the new operator in Java?
- What happens when an object is assigned to another object reference of the same class?
- Explain the utility of „this‟ keyword in java.
Week 4: String and String Buffer
String Class, String methods, String Arrays
- What is inheritance and how does it help in achieving reusability?
- Differentiate between overloading and overriding.
- Does a class inherit the constructors of its super class?
- What do you mean by signature of a method?
- What is a default constructor in java?
- Explain default constructor as its presence in .class file.
- Why cannot we create objects of Abstract classes?
- Can Abstract class contain all methods with proper definition?
- State two similarities between Interface and Abstract class
- Can Abstract class have final methods? Give reason to your answer
- What will happen if a class implements two interfaces and they both have a method with same name and signature?
- What are the major difference between an interface and a class?
- Can a Java class be private? What are the access modifiers applicable to classes in Java?
- How can a method be protected from being overridden? What benefit is achieved by preventing overriding?
- Prove that the fields in an interface are implicitly static and final.
- When do we declare a variable, a class final?
- What is the difference between an Interface and an Abstract class?
- Why Java does not support multiple inheritances?
- What is Object class in JAVA class hierarchy?
- How many types of „Inheritance‟ are in JAVA? What are those?
- Write down the differences between an Interface and an Abstract class with example?
- What is method overriding? Explain with a suitable example?
- How a class implements can interfaces in Java? Write a small program to show that
- “Constructors cannot be inherited or overridden but can be overloaded”- Do you agree with this statement? Explain it with proper example
- What happens when a sub-class object is assigned to a super class object reference? Explain with an example.
- What is the use of the keyword super? Is it absolutely necessary to use super?
- What is an interface?
Week 7: Reusability Properties (Package)
Defining Packages, Import and static import, jar utility
- What is the importance of using JAVA packages? Which package is imported by default in JAVA?
- What is method overloading in JAVA?
- What is a package? If a class is declared without any access modifiers, where may the class be accessed?
- Can we write the statement “import java.*; “--explain.
- How to create custom /user-defined packages in java? show it with an example
- Write the name of five built-in/System defined packages and their applications
- How do we design a package? How do we add a class or an interface to a package?
- What is the significance of the package statement? What is the significance of compiling a Java program with the – d option?
- Why method overriding is called Runtime Polymorphism in JAVA? Explain with an example.
- State differences between method overriding and method overloading.
- What all are the types of polymorphism present in Java. Explain.
- Discuss the different levels of access protection available in Java.
- What things should be kept in mind while overloading a function?
- What are Final variables and methods?
- How to use a particular package in a file? Explain the syntax
Week 8 and Week 9: Exception handling
Exception type, Exception class, Exception Handling, Error class, Runtime Exception class, Customized exception,
- What is an exception?
- State difference between Exception and Error in JAVA.
- Explain Run time exception in Java.
- What is exception handling in Java?
- How can the description of an exception be viewed?
- Can one try block have multiple catch blocks to handle different exceptions?
- How do we define a try block? How do we define a catch block?
- Discuss the class hierarchy of exception in Java? Which is the parent – most class in the hierarchy concerning exceptions?
- What happens precisely when the code in the try block throws an exception? What is the role of try statement there? What happens if the code is not written in try ( ) catch ( ) block if it is error-prone?
- How and why throw is used? Give proper Example.
- How can we create a user-defined/customized Exception class in java? Give proper Example.
- What is ArithmaticException? Write a code to demonstrate that.
- Distinguish between the „throw‟ and „throws‟ clause.
- How can multiple Catch Block be used in JAVA? Demonstrate that with proper Example
- What is the role of finally block in exception handling. State example
Week 10: Multithreading
Multitasking & Multithreading, Java and Multithreading, Creating Threads, life Cycle of a Thread, Thread Methods, Thread Priorities
- Write ways to create a Thread in Java. Write down the difference between them.
- What is a thread? What would happen if we call run () instead of start() on a thread object.
- What is thread priority? How the thread priorities can be obtained and set?
- Describe the complete life cycle of a thread.
- Explain with example to show which thread is currently running.
- Explain with example to show currently running thread‟s priority.
- What is the significance of run() and sleep () method in thread life cycle?
- What is Multithreading in JAVA? Demonstrate Multithreading using an example.
- Difference between notify() and notifyAll() methods.
- What are the two methods by which we may stop threads?
- Why suspend ( ) method was deprecated in Java2?
- What is the difference between suspending and stopping a thread?
- What do you mean by thread?
- What is main thread?
- How do you start a thread? What happens if a thread is started with the run ( ) method?
Week 11 and Week 12: Applet Programming &Wrapper Classes
Applet Creation, Difference between Applet and Application, Applet life cycle, Methods, Multithreaded applet, Event handling, Wrapper class
- What is an Applet? Should applets have constructors?
- What tags are mandatory when creating HTML to display an applet?
- What packages are mandatory when creating an applet to display something?
- Why the applet class should be kept as public?
- What are the steps involved in Applet development?
- What is the order of method invocation in an Applet?
- What do you mean by Multithreaded program?
- Can you write a Java class that could be used both as an applet as well as an application?
- Explain the life cycle of an Apple indicating the functions.
- What is the difference between Java applets and Java application programs?
- What is a wrapper class? Why wrapper classes are needed.
- List ant three attributes of Applet tag used in HTML. Explain the purpose of these attributes.
- What is an event and event listener? Give example.
- What is autoboxing and unboxing in JAVA?