0% found this document useful (0 votes)
45 views4 pages

Java Exam 2011 E.C

1. The document contains 7 coding questions from a Java exam. The first question defines a converter class that converts a Fahrenheit temperature to Celsius. The second defines a student class with name and roll number properties. The third demonstrates dynamic binding by overriding a method in a subclass. 2. The fourth defines an employee class that implements two interfaces. The fifth defines a Rectangle class with multiple constructors. The sixth defines abstract and concrete subclasses. The seventh overloads a method in a class.

Uploaded by

Magarsaa Qana'ii
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views4 pages

Java Exam 2011 E.C

1. The document contains 7 coding questions from a Java exam. The first question defines a converter class that converts a Fahrenheit temperature to Celsius. The second defines a student class with name and roll number properties. The third demonstrates dynamic binding by overriding a method in a subclass. 2. The fourth defines an employee class that implements two interfaces. The fifth defines a Rectangle class with multiple constructors. The sixth defines abstract and concrete subclasses. The seventh overloads a method in a class.

Uploaded by

Magarsaa Qana'ii
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Java 2011 Exam

1. public class converter {

public static void main(String[] args) {


int fahrenheit = 64;
double celsius = (5.0/9.0)*(fahrenheit-32);

System.out.println(celsius);
}

2. public class student {

String name;
int roll_no;
public static void main(String[] args) {
student obj = new student();
obj.name = "beharu";
obj.roll_no = 1057;

System.out.println(obj.name);
System.out.println(obj.roll_no);

}
}

3. public class Dbinding {

static class Name{


void Sname() {
System.out.println("jack");
}
}
static class Student extends Name{
void Sname() {
System.out.println("tom");
}
}
public static void main(String args[]) {
Name obj = new Student();
obj.Sname();
}
}

4. public interface developer {


void disp();
}
interface manager{
void show();
}

class employee implements developer, manager{


public void disp() {
System.out.println("ece section A");
Java 2011 Exam
}
public void show() {
System.out.println("ECE section B");
}

public static void main(String args[]) {


employee obj = new employee();
obj.disp();
obj.show();
}

5. A. public class Rectangle {

int length = 0, breadth = 0;


Rectangle(){
System.out.println(length*breadth);
}
Rectangle(int num1, int num2){
length = num1;
breadth = num2;
System.out.println(length*breadth);
}
Rectangle(int a, int b, int c){
length = a;
breadth = b;
System.out.println(length*breadth);
}
public static void main(String[] args) {
Rectangle obj = new Rectangle();
Rectangle obj1 = new Rectangle(2,3);
Rectangle obj2 = new Rectangle(1,2,3);

B. false
True

6. A. public class supsub {

static abstract class SuperClass{


SuperClass(){
System.out.println("This is constructor of abstract class");
}
abstract void a_methods();
void normal() {
System.out.println("This is a normal method of abstract class");
Java 2011 Exam
}
}

static class SubClass extends SuperClass{


void a_methods() {
System.out.println("This is abstract method");
}
}

public static void main(String[] args) {


SuperClass obj1 = new SubClass();
obj1.normal();
obj1.a_methods();

B. public class fibonacci {

public static void main(String[] args) {


int first = 0, second = 1, next = 0, num = 10;
int i = 1;
do {
System.out.println(first);
next = first + second;
first = second;
second = next;
i++;
}while(i <= num);
}

7. A. public class gradunder {

static class Degree{


void getDegree() {
System.out.println("I got a Degree");
}
}

static class Undergraduate extends Degree{


void getDegree() {
System.out.println("I am an Undergraduate");
}
}

public static void main(String[] args) {


Undergraduate obj = new Undergraduate();
obj.getDegree();
Java 2011 Exam
}

B. public class Overloading {

static int x = 0, y = 0, z = 0;
static class sum{
void add() {
System.out.println(x+y);
}
void add(int a, int b) {
x = a;
y = b;
System.out.println(a+b);
}
void add(int a, int b, int c) {
x = a;
y = b;
z = c;
System.out.println(a+b+c);
}
}

public static void main(String[] args) {


sum obj = new sum();
obj.add();
obj.add(2,3);
obj.add(4, 5, 6);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy