B.E. Mid-Semester Examination September 2016: LDRP Institute of Technology & Research, Gandhinagar
B.E. Mid-Semester Examination September 2016: LDRP Institute of Technology & Research, Gandhinagar
B.E. Mid-Semester Examination September 2016: LDRP Institute of Technology & Research, Gandhinagar
/
KADI SARVA VISHWAVIDYALAYA
ID
LDRP INSTITUTE OF TECHNOLOGY & RESEARCH, GANDHINAGAR
B.E. MID-SEMESTER EXAMINATION SEPTEMBER 2016
Date : 02/09/2016 Branch : CE & IT
Subject Name & Code: Object Oriented Programming with JAVA Semester : V
Subject Code: CE 505 / IT 505
Time : 8:30 AM to 10:00 AM Max. Marks : 30
Instructions: 1) All questions are compulsory.
2) Figures to the right indicate full marks.
3) Use of scientific calculator is permitted.
4) Indicate clearly, the options you attempt along with its respective question number.
5) Use the last page of main supplementary for rough work.
page 1 of 4
4. class Test { [2]
public static void main(String[] args) {
for(int i = 0; 1; i++)
{
System.out.println("Hello");
break;
}
}
}
}
6. class shft [2]
{
page 2 of 4
7. class rem { [2]
static int s;
public static void main(String [] args) {
rem p = new rem();
p.start();
System.out.println(s);
}
void start(){
int x = 7;
twice(x);
System.out.print(x + " ");
}
void twice(int x) {
x = x*2;
s = x;
}
}
8. [2]
class A{
static int i = 1111;
static{
i = i-- - --i; }
{
i = i++ + ++i;
}
}
class B extends A{
static{
i = --i - i--; }
{
i = ++i + i++;
}
}
class MainClass {
public static void main(String[] args) {
B b = new B();
System.out.println(b.i);
}
}
Q. II Find out error(s) if any in the following code and correct it and give
the output.
1. abstract class view{ [3]
protected void view(){
System.out.println("Constructor");
}
private void test(){
System.out.println("test Method");
}
private abstract void demo();
page 3 of 4
class dummy extends view{
dummy(){
System.out.println("Dummy Method");
super();
}
public static void main(String arg[]){
dummy d = new dummy();
d.demo();
}
private void demo(){
System.out.println("Demo Method");
}
}
page 4 of 4