Introduction to Java Programming language - B.Tech 5th Semester Examination, 2016
Introduction to Java Programming language
Instructions:
- There are Nine Questions in this Paper.
- Attempt five questions in all.
- Question No. 1 is Compulsory.
- The questions are of equal value.
-
What is the output of this program?
class bitwise_operator { public static void main (String args[]) { int var1 = 42; int var2 = ~var1; System.out.print(var1 + " " + var2); } } -
Which of these have highest precedence?
-
What is the output of this program?
class operators { public static void main(String args[]) { int var1 = 5; int var2 = 6; int var3; var3 = ++var2 * var1 / var2 + var2; System.out.print(var3); } } -
What is the output of this program?
class output { public static void main(String args[]) { int x, y; x = 10; x++; --x; y = x++; System.out.println(x + " " + y); } } -
What is the output of this program?
class conversion { public static void main(String args[]) { double a = 295.04; int b = 300; byte c = (byte) a; byte d = (byte) b; System.out.println(c + " " + d); } } -
What is the default value of Boolean variable?
-
What is the output of this program?
class array_output { public static void main(String args[]) { char array_variable[] = new char[10]; for (int i=0; i<10; ++i) { array_variable[i] = '1'; System.out.print(array_variable[i] + " "); i++; } } } -
What is the output of this program?
class exception_handling { public static void main(String args[]) { try { System.out.print("Hello" + " " + 1/0); } catch (ArithmeticException e) { System.out.print("World"); } } } -
What is the output of this program?
class overload { int y; int x; void add(int a) { x = a + 1; } void add(int a, int b) { x = a + 2; } } class overload_methods { public static void main(String args[]) { overload obj = new overload(); int a = 0; obj.add(6, 7); System.out.println(obj.x); } } -
What is the output of this program?
class A { public int i; private int j; } class B extends A { void display() { super.j = super.i + 1; System.out.println(super.i + " " + super.j); } } class inheritance { public static void main(String args[]) { B obj = new B(); obj.i = 1; obj.j = 2; obj.display(); } }
-
What is the difference between the C, C++ and Java?
-
Write a program that reads an integer and check whether it is prime number or not.
-
What do you understand by polymorphism? Explain with examples.
-
What do you understand by precedence and Associativity? Explain with examples.
-
What is a constructor? Give its properties. How do we declare/define it? Can they be overloaded? Explain types of constructors with example.
-
What is exception-handling? What are the statements used for it? Show an example.
-
Give the definition (1-2 Lines) and an example of the following: i. Thread Class, ii. AWT, iii. JDBC, iv. JVM.
-
Difference between the following with example: i. Break and continue, ii. Abstract class and interface.
-
What is exception-handling? What are the statements used for it? Show an example.
-
What is inheritance in java? Explain different types of inheritance.
-
Create an abstract class Discount Policy. It should have a single abstract method compute Discount that will return the discount for the purchase of a given number of a single item. The method has two parameters, count and itemCost.
-
Write a program to find largest and second largest element in an array.
-
Write a program to design a class account using the inheritance and static keyword that shows all function of bank (withdrawal, deposit).
-
Write a program to create a thread that Implement the Runnable interface.
-
Write a program to create a Simple class to find out the Area and perimeter of rectangle and box using super and this keyword.
-
Write a program to find the factorial of a given number using Recursion.