INTRODUCTION TO JAVA PROGRAMMING LANGUAGE - B.Tech 5th Semester Exam., 2018
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
-
Java is an example of ________ language.
-
The mother tongue of a computer is:
-
You have the following code in a file called Test.java:
class Base{ public static void main(String[] args){ System.out.println("Hello"); } } public class Test extends Base{}What will happen if you try to compile and run this? -
Which of the following are valid declarations? (Note: None of the literals used here contain the character O, they are all zeroes.)
-
What is the result of trying to compile and run this program?
public class Test{ public static void main(String[] args){ int[] a = {1}; Test t = new Test(); t.increment(a); System.out.println(a[a.length-1]); } void increment(int[] i){ i[i.length - 1]++; } } -
Is this legal?
long longArr[]; int intArr[] = {7, 8, 9}; longArr = intArr; -
What is the result of attempting to compile and run this?
interface A{ void aMethod(); } public class Test implements A{ void aMethod(){ System.out.println("hello"); } public static void main(String[] args){ Test t = new Test(); t.aMethod(); } } -
What are the class variables?
-
Explain the following code sample:
result = someCondition ? value1 : value2; -
Character strings are represented by the class java.lang.String.
-
Why is Java called machine independent language? Explain the functionality of JVM.
-
What is the main difference between an application and applet?
-
What are the wrapper classes? Explain their uses.
-
What does a dynamic Billboard Applet do? What are the three main classes that the applet contain?
-
What is the difference between process-based and thread-based multitasking? Give the two ways by which a thread can be created using Java.
-
What is RMI? What is the difference between Naming.bind and Naming.rebind methods? Write a short code to invoke a remote method using Java RMI.
-
Write an Applet (Use swings) to display the outputs:
-
What are the characteristics of JDBC? What are the various steps for using JDBC? Write a program to demonstrate these steps.
-
What is the main purpose of a container component in swing?
-
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.
• A private int data field named speed that specifies the speed of the fan (default SLOW).
• A private boolean data field named on that specifies whether the fan is on (default false).
• A private double data field named radius that specifies the radius of the fan (default 5).
• A string data field named colour that specifies the colour of the fan (default blue).
• The accessor and mutator methods for all four data fields.
• A no-arg constructor that creates a default fan.
• A method named toString() that returns a string description for the fan. If the fan is on, the method returns the fan speed, colour, and radius in one combined string. If the fan is not on, the method returns fan colour and radius along with the string "fan is off" in one combined string.
Implement the class. Write a test program that creates two Fan objects. Assign maximum speed, radius 10, colour yellow, and turn it onto the first object. Assign medium speed, radius 5, colour blue, and turn it off to the second object. Display the objects by invoking their toString method.
-
Write a program in Java to demonstrate communication using TCP/IP i.e., using sockets. Write a separate code for a server and client program. The program should display the contents of the file specified in a server onto the client.