Java Programming 2017-18 Back Examination Previous Year Paper Solution
Short Questions

Q1. Answer the following questions: [Marks: 2 x 10]

a) Mention some of the separators used in java programming?

Ans: A separator is a symbol that is used to separate a group of code from one another is called as separators in java. The most commonly used separators are:

  1. Semicolon(;): Used to separate or terminate the statement.
  2. Comma(,): Used to separate identifiers in variable declarations.
  3. Period(.): Used to separate package names from sub-packages and classes. It is also used to separate variables or methods from its object or instance.
  4. Brackets([]): It is used in array declaration.

b) How to create one dimensional array?

Ans: There are two ways to create one dimensional array in Java shown below:

int[] array = {1, 2, 3};

The simplest way to create an array by enclosing its values in curly braces separated by commas

int[] array = new int[3];
array[0] = 1;
array[1] = 2;
array[2] = 3;

c) What is meant by Reflection?

Ans: Reflection is a language’s ability to inspect and dynamically call classes, methods, attributes, etc. at runtime.

d) What is static in java?

Ans: In Java, a static member is a member of a class that isn’t associated with an instance of a class. Instead, the member belongs to the class itself. As a result, you can access the static member without first creating a class instance.

e) What is the relation between an event-listener interface and an event adapter class?

Ans: An event-listener interface defines the methods that must be implemented by an event handler for a particular event. An event adapter provides a default implementation of an event-listener interface.

f) Why swing components are called lightweight components?

Ans: Swing is considered lightweight because it is fully implemented in Java, without calling the native operating system for drawing the graphical user interface components.

g) What are proxies? How they are advantageous?

Ans: A web proxy is some kind of intermediate between a web user and an online resource. A proxy-based connection provides a gateway for your web request and the data you will receive back from the website.

Proxies can hide or modify your web request data and filter the website content preventing you from getting unwanted information. This also ensures anonymous web browsing and data collection from your end. 

h) Distinguish between static and dynamic binding in java.

Ans: Difference between static and dynamic binding:

Static BindingDynamic Binding
1. It is resolved at compile time. 1. It is resolved at run time.
2. Overloading is an example of static binding2. Method overriding is the example of Dynamic binding
3. private, final and static methods and variables uses static binding3. Virtual methods use dynamic binding

i) What is multithreading in java?

Ans: The process of executing multiple threads simultaneously to maximum utilization of CPU is known as multithreading.

j) What is object slicing?

Ans: Slicing is where you assign an object of a derived class to an instance of a base class, thereby losing part of the information