0% found this document useful (0 votes)
161 views

Sample Questions - Self Practice (LBJ Module 3 - Java Basics)

The document contains 10 sample questions to test Java programming concepts. The questions cover topics like inheritance, classes vs interfaces, constructors, Unicode, naming conventions, output of code snippets, object references, String handling, and converting integers to Roman numerals.

Uploaded by

Prajakta More
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views

Sample Questions - Self Practice (LBJ Module 3 - Java Basics)

The document contains 10 sample questions to test Java programming concepts. The questions cover topics like inheritance, classes vs interfaces, constructors, Unicode, naming conventions, output of code snippets, object references, String handling, and converting integers to Roman numerals.

Uploaded by

Prajakta More
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Sample Questions – Self Practice

(LBJ Module 3 – Java Basics)


Q.1) Which keyword is used to inherit a class?

Q.2) What is the difference between class and an interface?

Q.3) What is the benefit of constructor in a class?

Q.4) What is Unicode and which datatype of Java supports Unicode?

Q.5) What are some of the naming conventions that we follow in any Java program?

Q.6) What will be the output of below Java program:


class CharTest {
public static void main(String args[]) {
char ch1, ch2;
ch1 = 65;
ch2 = 'B';
System.out.println(ch1 + ' ' + ch2);
}
}

Q.7) What will be the output of below Java program:


class Super {
public int index = 1;
}

class App extends Super {

public App(int index) {


index = index;
}

public static void main(String args[]) {


App myApp = new App(10);
System.out.println(myApp.index);
}
}

Q.8) What will be the output of below Java program:


class PC {
String memory = "1GB";
}
class Workshop {
public static void main(String args[]) {
PC dell = new PC();
repair(dell);
System.out.println(dell.memory);
}
public static void repair(PC pc) {
pc = new PC();
pc.memory = "2GB";
}
}

Q.9) What will be the output of below Java program:


class MyStringDemo {
public static void main(String[] args) {
String str1 = "LTI";
String str2 = str1;
str1 = "LTI Mumbai";
if(str1==str2) {
System.out.println("Both String objects are equal");
}else {
System.out.println("Both String objects are NOT equal");
}
}
}

Q.10) Write a Java program that converts a positive integer into the Roman number system.
The Roman number system has digits:
I=1
V=5
X = 10
L = 50
C = 100
D = 500
M = 1,000

You might also like