Professional Documents
Culture Documents
QB Java-1 Sem-1 T1
QB Java-1 Sem-1 T1
QB Java-1 Sem-1 T1
11 1 Which of the following isn’t a characteristic of High level languages? A 1 machine code platform independent interactive execution user-friendly
Which of the following translates the program into machine language line by
12 1 C 1 Compiler Translator Interpreter none of the above
line?
language which is
Human readable like language with small language with big difficult to understand
13 1 High level language is a ….. A 1
language. program size. program size. and not human
readable.
Difficult to understand
Human readable like language with big language with small
14 1 Low level language is ….. D 1 and readability is
language. program size. program size.
questionable.
15 1 The instructions like MOV or ADD are called as ______ A 0.5 OP-Code Operators Commands Operand
TOPIC NAME:- Algorithm and Flowchart(MCQS)
A Procedure for A Mathematical A Pictorial
16 1 An algorithm is __________? B 1 A problem
Solving a Problem Problem representation
17 1 Actual instructions in flowchart are represented in________ B 1 Circle Boxes Arrows Lines
The following box denotes?
18 1 A 1 Decision Inititation Initialization Process
19 1 Which of the following represents two different conditions in a flowchart? B 1 Rectangle Diamond Circle Parallelogram
20 1 Which of the following represents input and output operation in a flowchart? C 1 Diamond Rectangle Parallelogram Circle
TOPIC NAME:- Algorithm and Flowchart(REPRESENTATION)
21 1 Write an algorithm and draw a flowchart to calculate area of rectangle. 3
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
22 1 Write an algorithm and draw a flowchart to calculate percentage of the student. 3
Write an algorithm and draw a flowchart to calculate the interest of a bank
23 1 4
deposite.
Write an algorithm and draw a flowchart to convert input celsius degree
24 1 4
temperature into its equivalent fahrenheit degree. Use formula F= (9/5)*C +32
25 1 Write an algorithm and draw a flowchart to swap two input numbers. 4
Sketch flowchart to convert seconds into hour, minute and second. (Hint : 3700
26 1 3
seconds => 1 hr , 1 minute , 40 second)
Write an algorithm and draw a flowchart to check whether given number is
27 1 3
positive or negative.
Write an algorithm and draw a flowchart to find out smallest number out of two
28 1 4
numbers.
Write an algorithm and draw a flowchart to find out maximum number out of
29 1 4
three numbers.
Write an algorithm and draw a flowchart to arrange the numbers x,y,z in
30 1 4
descending order.
31 1 Write an algorithm to determine whether the given year is a leap year or not. 2
Write an algorithm and draw the flowchart to accept N numbers and count how
34 1 4
many of them where odd and also compute sum of all these odd numbers.
Write an algorithm and Draw the flow chart to solve following series 1! +2! +3!
35 1 4
+…. +n!
36 1 Draw a flowchart to print first N Fibonacci Numbers (0, 1, 1, 2, 3, 5, 8,…). 3
Draw the flowchart to add the digits of the given number. Then Check the
37 1 4
weather the final sum is prime or not.
Draw flowchart that first converts given binary number to its decimal equivalent
38 1 number and then displays reverse of that decimal number. Take input: 1111011 4
42 2 Which component is used to compile, debug and execute the java programs? C 1 JRE JIT JDK JVM
43 2 ____________is used to fix bugs in Java. D 1 JRE JIT JDB JDK
___________is the system that consists of a set of tools that are used for
44 2 C 1 JRE JIT JDK JVM
developing and running Java programs
The feature of java that helps in managing multiple tasks simultaneously is
45 2 B 1 multi-tasking multithreading distributed dynamic
called______
logical and physical
46 2 What are objects in object oriented programming languages? C 1 logical entities physical entities non of the above
entities
Which of the following is the correct syntax for suggesting that the JVM System.setGarbageColl
47 2 C 1 System.free() System.out.gc() System.gc()
performs garbage collection? ection()
Which component is responsible for converting bytecode into machine specific Java Virtual
48 2 B 0.5 Java Virtual Machine Java Development Kit Java Bytecode Module
code? Mechanism
49 2 Which of the following is not a Java features? C 0.5 Dynamic Architecture Neutral Use of pointers Object-oriented
TOPIC NAME:- Basic Structure of Program, Comments- Single Line and Multiline (MCQS)
/* //
/System.Out.Println("H
50 2 Correct way of commenting a single line is? B 0.5 System.out.printf("Hell System.out.println("He /*print("Hello");*/
ello ") ;/
o"); llo..");
specifies that a method specifies that a method specifies that a method specifies that a method
What do you mean by “void” in the statement “public static void main(String[]
51 2 A 0.5 should not have a should have a return should have an int type should not have a char
args)”?
return value value return value type return value
String args[] in main method are used for?
public static void main (String args[])
Passing arguments at Passing arguments at Counting number of To hide the main
52 2 { B 0.5
compile time run time words method from misuse
//
}
TOPIC NAME:- Identifiers, Constants, Separators, Variables, Keywords,Literals (MCQS)
Which of the following will compile correctly
1. short myshort = 99S;
2. String name = 'Excellent tutorial Mr Green';
53 2 D 1 1&2 1,3&4 1&4 4
3. char c = 17c;
4. int z = 015;
54 2 Which of these cannot be used for a variable name in Java? C 1 identifier & keyword identifier keyword none of the mentioned
55 2 Which one of the following is incorrect for variable name? B 1 _a 1a a1 _1a
Which of the following are Java keywords?
1. double
56 2 2. Switch C 1 1&2 1,2&4 1&4 1,3&4
3. then
4. instanceof
57 2 Which of the following are not keyword/s or reserved word/s in Java? B 1 if then goto while
58 2 Which are keywords in Java? B 1 NULL friend sizeof extends
59 2 Which one of the following is incorrect for variable name ? A 1 new sum count flag
60 2 Which one of the following is incorrect for variable name? D 0.5 _abc abc_abc abc123 abc def
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
int a=10;
61 2 Which of the following is not the correct java statement? B 0.5 int a = 10; none of above. int a,b,c=20;
a + = 10;
62 2 Which one is invalid variable name? C 0.5 a1 a 3a a_3
TOPIC NAME:- Data Types- Primitive | Non-Primitive, Typecasting (MCQS)
63 2 Which of the following is a non-primitive data-type in java? C 1 boolean character array float
64 2 What is the size of a boolean variable in java? A 1 1 byte 2 bytes 4 bytes 8 bytes
65 2 The range of a float is ______ D 1 -32768 to '+32767 -128 to '+127 -1.7e308 to '+1.7e308 -3.4e38 to +'3.4e18
A data type which can
A data type which A data type whose size
hold more precision
66 2 What is a higher data type in Java language? D 1 holds more data than is more than other All the above
digits than other data
other data types data types
types
Give Output.
Boolean b1 = new Boolean("true");
67 2 Boolean b2 = new Boolean("false"); C 1 Comiler error RunTime error truefalsefalse truetruetrue
Boolean b3 = new Boolean("Infosense Global Solution");
System.out.println("" + b1+b2+b3);
68 2 Which of the following lines will compile without warning or error. D 1 float f=1.3; char c = “a”; byte b=257; int I = 10;
What is the output of the following Java Code?
int a=9;
69 2 A 1 4.0 4.5 5 none of the above
float b = a/2;
System.out.println(b);
What is the output of the below Java code snippet?
char ch = 'A';
70 2 int a = ch + 1; C 1 66 A B 65
ch = (char)a;
System.out.println(ch);
What is the output of the below Java code snippet?
71 2 float a = 8.2/2; D 1 4.1 4.0 4 Compile- time error
System.out.println(a);
What is the output of the below Java code snippet?
72 2 float a = 10.2f/2; A 1 5.1 5 5.0 Compile- time error
System.out.println(a);
If an expression contains double, int, float, long, then the whole expression will
73 2 C 1 long int double float
be promoted into which of these data types?
Floating-point value Floating-point value
Integer value assigned Integer value assigned
74 2 What is Truncation in Java? A 1 assigned to an integer assigned to a Floating
to floating type to an integer type
type type
What is the output of the following java code?
class conversion
{
public static void main(String args[])
{
double a = 295.04;
75 2 B 1 38 43 39 44 295 300 295.04 300
int b = 300;
byte c = (byte) a;
byte d = (byte) b;
System.out.println(c + " " + d);
}
}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
76 2 Which of the following automatic type conversion will be possible? C 1 short to int byte to int int to long long to int
What is the type and value of the following expression? (Notice the integer
77 2 division) D 1 int -5 double -4.5 int -4 double -5.0
-4 + 1/2 + 2*-3 + 5.0
what will be output by the following line of code?
78 2 D 1 12 14 6 None of these
System.out.println(01014);
What is the output of the following Java Code?
class Public
Compile time error
{ Compile time error Compile time error
(Reason: sequence of
static public void main(String[] LJ) (Reason: class name (Reason: 10 is int can
public static void
79 2 { B 1 can not be Public x+ LJIET is best college not assigned to the
main() can not be
float x = 10; because it is reserve float. It should be
change as static public
System.out.println("x+ LJIET is best college"); word) 10.0f)
void main() function)
}
}
What is the output of the following Java Code?
class p1 {
public static void main(String[] arg) {
byte a=20; short b = 30; 160.0LJIET50COLLEGE6 160.0+LJIET+50+COLLE 160.0LJIET2030COLLEG
80 2 D 1 160LJIET50COLLEGE60
int c= 40; long d= 50; 0.0 GE+60.0 E60.0
float f = 60; double g = 70;
System.out.println(g+d+c+"LJIET"+a+b+"COLLEGE"+f);
}}
What is the output of the Java code snippet?
class Test1{ public static void main(String args[])
{
81 2 float x = Math.PI; B 0.5 3.14f Error 3 3.0
int y = (int) Math.abs(x);
System.out.print(y);
}}
What is the output of the Java code snippet?
class Test{
82 2 public static void main(String args[]) { C 0.5 101 202 40 2
System.out.println(0b00101000);
}}
double<
83 2 Choose correct sequence from following options: B 0.5 int<byte<short<double byte<short<int<double short<byte<int<double
int<byte<short
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
84 2 int a=70000; D 0.5 7000 -70000 2 4464
short b=(short)a;
System.out.println(b);
}}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What will be the output of the following code?
class MCQ19{
public static void main(String args[]){
Compile time error :
double a = 20; Compile time error :
85 2 C 0.5 83 b = 83 incompatible type
int b = a +(int) 63; Can not find symbol int
from double to int
System.out.println(b);
}
}
Which of the following will not compiled correctly?
1) short s = 1024;
2) String s1 = ‘JAVA EXAM’;
86 2 3) byte b = 256; D 0.5 1&4 1,5 1,3,2 2,3,4
4) char c = 18c;
5) int v = 015;
6) float f = 89.89f;
int a = 10; int a = 10; int a = 10.0f;
87 2 Which is the correct statement to typecast int to float. C 0.5 int a = 10f;
float b = (int) a; float b = a; Float b = 5;
What will be the output of following code?
class Test {
public static void main (String[] args)
{
double a = -22500.2;
88 2 int b = -294; D 0.5 22500,40 -22500,39 22500,38 -22500 ,-38
short c = (short) a;
byte d = (byte) b;
System.out.println(c + " ," + d);
}
}
TOPIC NAME:- Classification of Operators , Evaluation of Expression, Precedence and Associativity (MCQS)
What gets printed when the following program is compiled and run. Select the
one correct answer.
public class incr{
public static void main(String args[]) {
int i, j;
89 2 i=j= 3; A 1 4486 4488 4466 4386
int n = 2 * ++i;
int m=2 * j++;
System.out.println(i + " " + j + " " + n + " " + m);
}
}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of the Java code snippet?
class Main
{
public static void main(String args[])
{
int a=5, b=10, c=15;
90 2 A 1 2 20 3 2 20 5 2 10 5 2 10 3
a -= 3;
b *= 2;
c /= 5;
System.out.println(a +" " + b + " " + c);
}
}
What is the output of the Java code snippet?
class Main
{
public static void main(String args[])
{
91 2 D 1 50 80 40 Compiler error
Int a=10, b=6;
int c = a+b*5;
System.out.println(c);
}
}
What is the output of the Java code snippet?
class Main
{
public static void main(String args[])
{
int a=10, b=20;
92 2 C 1 20,40 22,40 20,38 22,38
int c = a++*2;
int d = --b*2;
System.out.println(c +"," + d);
}
}
93 2 Increment and Decrement arithmetic operators in Java has which Associativity? D 1 Left to Right Left to Left Right to Right Right to left
What is the output of the Java code snippet?
class Main
{
public static void main(String args[])
{
94 2 C 1 error 1 2 3
int i=0;
int j=i++ + ++i;
System.out.println(j);
}
}
Both integers and
Floating-point
95 2 Modulus operator, %, can be applied to which of these? C 1 Integers Floating-point none of these
numbers
numbers
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of the Java code snippet?
class Test
{
public static void main(String args[])
{
double var1 = 1 + 5;
96 2 D 1 1,1 0,1 1.5,1 error
double var2 = var1 / 4;
int var3 = 1 + 5;
var4 = var3 / 4;
System.out.print(var2 + "," + var4);
}
}
97 2 What is the other name for Relational Operators in Java? C 1 Comparison operators Conditional operators A and B None of the above
How many minimum number of operands are required to use Comparison
98 2 B 1 1 2 3 4
operators in Java?
What are the types of data that can be used along with Relational operators in
99 2 D 1 char, boolean, Object byte, short, int, long float, double All the above
Java?
What is the output of the Java code snippet?
class Test3
{
public static void main(String args[])
{
100 2 A 1 true false Compiler error Runtime error
boolean b=false;
b = !b;
System.out.println(b);
}
}
What is the output of the Java code snippet?
class bitwise_operator
{
public static void main(String args[])
{
int a = 3;
101 2 A 1 72 75 27 57
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d);
}
}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of the Java code snippet?
class rightshift_operator
{
public static void main(String args[])
{
102 2 int x; B 1 10 5 2 20
x = 10;
x = x >> 1;
System.out.println(x);
}
}
What is the output of the Java code snippet?
class Test
{
public static void main(String args[])
{
103 2 byte b = 0b0000101; C 1 5,0 5,15 5,5 0,5
System.out.print(b + ",");
b &= 0b00001111;
System.out.print(b);
}
}
What is the output of the Java code snippet?
class ternary_operator
{
public static void main(String args[])
{
int x = 3;
104 2 C 1 0 1 3 -4
int y = ~ x;
int z;
z = x > y ? x : y;
System.out.print(z);
}
}
What is the output of the Java code snippet?
class Output
{
public static void main(String args[])
{
105 2 boolean a = true; D 1 0 1 true false
boolean b = false;
boolean c = a ^ b;
System.out.println(!c);
}
}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of the Java code snippet?
class Test
{
public static void main(String[] args)
{
int a=4, b=8;
106 2 C 0.5 true,32,1 true,16,1 false,32,1 false,32,2
boolean c = a>1 ^ b<10;
int d=a<<3;
int e=a>>2;
System.out.print(c+","+d+","+e);
}
}
What is the output of Java program below?
byte b = 25;
107 2 b++; A 0.5 Compile time error 25 26 27
b = b+1;
System.out.println(b);
What is the output of the Java code snippet below?
int a = 4, b=7;
108 2 B 0.5 4 120 150 3
int result = (true?a&b:a|b)>3?120:150;
System.out.println(result);
109 2 _______is a Short circuit AND operator and _____is a bitwise AND operator. A 0.5 && and & & and && ! and != ~ and &&
With x = 0, which of the following are legal lines of Java code for changing the
value of x to 1?
1. x++;
110 2 C 0.5 1, 2 & 3 1&4 1, 2, 3 & 4 3&2
2. x = x + 1;
3. x += 1;
4. x =+ 1;
What will be the output of the following Java program?
class Modulus
{
public static void main(String args[])
{
double a = 25.64; 5.640000000000001 5.640000000000001
111 2 A 0.5 55 5 5.640000000000001
int b = 25; 5 5.0
a = a % 10;
b = b % 10;
System.out.println(a + " " + b);
}
}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of Java program below?
class Output
{
public static void main(String args[])
{
int a = 1;
int b = 2;
112 2 int c = ++b; B 0.5 3133 3531 3333 3513
int d = a++;
c++;
b--;
++a;
System.out.println(a++ + " " + --b*++a + " " + --c + " " + d++);
}
}
What is the output of the Java code snippet?
class Test1{
public static void main(String args[]){
int a = 10, b = 20;
byte c = 121;
113 2 a++; A 0.5 Error 11 21 122 1121122 1021121
++b;
c = c + 1;
System.out.println(a + " "+ b + " "+ " " + c);
}
}
What is the output of the Java code snippet?
class Test1{
public static void main(String exam[]){
byte a = 126; char ch = 'f'; int c = a % 1;
a+=2;
ch=++ch;
114 2 D 1 $-25 229 128g0 127f0 25 229 #-25 230
System.out.print(ch+a+c+" ");
a-=1;
ch=ch--;
System.out.print(ch+a+c);
}
}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of the Java code snippet?
class Test1{
public static void main(String args[]){
int b = 10, c = 20;
float a;
boolean d;
115 2 d = b < c; B 1 21 118.0 21.0 118
b+=++b;
c-=--c;
a = (d) ? b : c;
System.out.println(a + 'a');
}
}
What is the output of the Java code snippet?
class test1{
public static void Main(String args[]){
float num1 = 12.2f;
double num2 = 24.4D;
116 2 num1 *= num2; A 1 Error 12.2,24.4 24.4,12.2 24,12
num2 = num1 / num2;
num1 /= num2;
System.out.println(num1 + "," +(int)num2);
}
}
What is the output of following program?
class Ljiet {
public static void main(String args[]) {
117 2 double a = 10; C 0.5 0 Compile time error Infinity Run time error
int b = -0;
System.out.println(a/b);
}}
What is the output of the following Java Code?
class Test {
public static void main(String[] arg) {
int a = 10,b = 20;
118 2 B 1 777 999.0 999 777.0
a++; b++;
double x= (a>50)?777:((b>100)?888:999);
System.out.println(x);
}}
What is the output of following program?
class Test1{public static void main(String[] args){
119 2 B 0.5 2 2.0 2.5 2.50
System.out.println(5/2%5.0);
}}
What is the order of precedence (highest to lowest) of following operators?
120 2 C 0.5 3-1-2-5-6-4 1-4-6-5-2-3 4-5-6-2-1-3 3-1-2-6-4-5
Operators to consider: 1. && 2. ^ 3. ?: 4. ! 5. % 6. >>
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of the Java code snippet?
class Test1{public static void main(String args[])
{
121 2 int a=8; C 1 16 17 18 19
a+=++a;
System.out.println(++a);
}}
What is the output of the Java code snippet?
class Test1{ public static void main(String args[])
122 2 { A 1 true false 120 100
System.out.println(100 % 20 <= 20 - 5 + 100 % 10 - 80>>2 == 5 >= 1 != !!true);
}}
Fill in the blanks given inside code to get output: 65
class Test1{public static void main(String args[])
{
int a=5, b=6;
123 2 a__=b; D 1 +,*, + = /, *, *= *, /, *= *, /, /=
b=a__b;
a__b;
System.out.print(a+””+b);
}}
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
124 2 D 0.5 55 56 -55 -56
int b=55;
System.out.println(~b);
}}
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
125 2 float a=10.0, b=5.5, c; D 0.5 15.5 15 10 compile error
c=a+b;
System.out.println(c);
}}
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
int p;
126 2 C 0.5 28 37 38 18
int k=18;
p = (6*++k)/3;
System.out.println(p);
}}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
byte x = 127;
127 2 D 0.5 127 128 129 -127
x++;
x++;
System.out.print(x);
}}
By executing this below code what will be the value of x and which variable’s
value is assign to x.
class Test
{
128 2 C 0.5 Output:5,x=a Output:-5,x=b Output:5,x=c Output:0,x=garbage
public static void main(String args[])
{ int a=5,b=5,c=5,x;
x=(a>b)?((a>c)?a:c):((b>c)?b:c);
System.out.println(x); }}
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
int x = -5;
129 2 B 0.5 5 -5 -4 4
int y = ~ x;
int z;
z = x != y ? x : y;
System.out.print(z); }}
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
130 2 byte b=10; D 0.5 10 11 12 compile error
b=b+1;
System.out.println(b);
}}
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
boolean a=true;
131 2 C 0.5 true false Compile error 0
boolean b=false;
int c= a&b;
System.out.println(c);
}}
Write the value that will be assigned to variable C after executing the following
132 2 B 0.5 100 101 99 200
statement: C = 125-15*4/3-10+6;
What will be the output of the following code?
class MCQ15{
public static void main(String args[]){
int a = (int)2.5f;
133 2 C 0.5 2 Compile time error 4 6
int c = ++a - a++;
System.out.println(a);
}
}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of following code?
class MCQ12{
public static void main(String args[]){
Boolean a = True;
134 2 D 0.5 true false b = true Compile time error
boolean b = !a;
System.out.println("b = "+b);
}
}
What is the output of following program?
class MCQ11{
public static void main(String args[]){
int a = 2;
int b = 5;
135 2 D 0.5 2 5 25 7
int c = 10;
c = a*b-c+a;
System.out.println(c+b);
}
}
What is the output of the following program?
class MCQ22{
public static void main (String args[])
{
int a = 10;
136 2 D 1 10 20 158 160
int b = 20;
int c = (a>>3)*(b<<3)+(b>>5);
System.out.println(c);
}
}
What is the output of the following program?
class MCQ23 {
public static void main (String args[])
{
int a = 10;
137 2 C 1 110 5 29 10
int b = 3;
int c = (a|b) * (a&b) + a - b;
System.out.println(c);
}
}
What is the output of the following program?
class MCQ21{
public static void main (String args[])
{
138 2 int i=3,j=2; C 1 4 compile time error -6 2
int ans = --i*i+j-j++*6;
System.out.println(ans);
}
}
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What will be the output of the following code?
class GFG{
public static void main(String[ ] args)
{
139 2 B 0.5 7.0 8.0 Compile time Error 8.0f
float c =3.5f + 4.5f;
System.out.println(c);
}
}
What is the output of the Java code snippet with Ternary operator?
140 2 int num = false?10:20; C 0.5 false 10 20 num
System.out.println(num);
What will be the output of the following code snippet?
class Boolean_Operators
{
public static void main(String args[])
{
boolean a = 6;
It compiles but prints
141 2 boolean b = 5; D 0.5 3 & -7 -3 & -7 It gives Error
nothing
boolean f = (~ a & b) | (a & ~ b);
boolean g =~ a;
System.out.println("~ a&b | a&~ b = " + f);
System.out.println("~ a = " + g);
}
}
What is the output of the following Java Code snippet?
int x = 3;
142 2 int y = 5; C 0.5 8 “8” z error
float z = x + y;
System.out.print("z");
What is the output of the following Java Code?
class Main
{ public static void main(String args[])
143 2 {int x=2; D 1 error 2 2.0 15.0
float y = x++ + x++ * --x / x++ - --x + 3>>1 | 13;
System.out.println(y);
}}
What is the output of the following Java Code ?
class Java
{ public static void main(String args[])
144 2 {byte L=12; A 1 error 24 24.0 0
L= L+ 12;
System.out.println(L);
}}
What is the output of the following Java Code ?
class Java
{ public static void main(String args[])
145 2 D 1 25 9 7 8
{ int L=( 9 > 11 ) ? 25 : (( 25 > 23 ) ? 8 : 7 );
System.out.println(L);
}}
TOPIC NAME:- Classification of Operators (PROGRAMS)
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
Write a program that displays the area and perimeter of a circle that has a
146 2 radius of 5 using the following formula: perimeter = 2 * radius * pi area = 3
radius * radius * pi
WAP to calculate the Area of a Circle, Area and Perimeter of rectangle, Area of
147 2 3
Triangle.
WAP that reads two nos. from key board and gives their addition, subtraction,
148 2 3
multiplication, division and modulo.
WAP to enter three subject marks, and calculate total, percentage of student
149 2 4
and display the same in proper format.
150 2 WAP to convert days into months and days. 3
Write a program that reads a Celsius degree in a double value from the console,
151 2 then converts it to Fahrenheit and displays the result. The formula for the 4
conversion is as follows: fahrenheit = (9 / 5) * celsius + 32.
152 2 WAP to swap two numbers using temporary variable. 4
153 2 WAP to swap two numbers without using temporary variable. 4
Assume a runner runs 15 kilometers in 50 minutes and 30 seconds. Write a
154 2 program that displays the average speed in miles per hour. (Note that 1 mile is 4
1.6 kilometers.)
Write a program that prompts the user to enter two points (x1, y1) and (x2, y2)
155 2 and displays their distance between them. The formula for computing the 4
distance is √(x2 - x1)2 + (y2 - y1)2.
Write a program that prompts the user to enter a two numbers using
156 2 4
commandline argument & find maximum number using ternary operator.
TOPIC NAME:- Command line argument, Use of Wrapper Class, Scanner class and its methods (MCQS)
What will be the output of the following Java program, Command line execution
is done as – java Output command Line 10 A b 4 N
class Output
{
public static void main(String args[])
{
157 2 D 1 Output36 Line36 command Line 10 command36
System.out.print(args[0]);
int n1=Integer.parseInt(args[2]);
int n2=Integer.parseInt(args[5]);
System.out.print(n2*n1-n2);
}
}
Which of the following is the correct method to accept integer value from user
158 2 using B 0.5 NextInt() nextInt() nextInteger() NextInteger()
scanner class
Choose the correct mapping of Primitive Data Types and Wrapper Classes
below?
I. boolean = Boolean, char = Character Both I and IV are
159 2 D 0.5 Only I is Correct Only IV is Correct I,II,III are Correct
II. byte = Byte, short = Short, int = Integer, long = Long Correct
III. float = Float, double = Double
IV. str=String , arr=Array
TOPIC NAME:- Math class and its Methods (MCQS)
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What is the output of the Java code snippet?
class Output
{
public static void main(String args[])
{
160 2 double x = 3.1; D 1 true false 3.1 4.5
double y = 4.5;
double z = Math.max( x, y );
System.out.print(z);
}
}
What is the output of the Java code snippet?
class Output
{
public static void main(String args[])
{
161 2 double x = 2.0; D 1 8.0 2.0 4.0 error
double y = 3.0;
int z = Math.pow( x, y );
System.out.print(z);
}
}
What is the output of the Java code snippet?
class Output
{
public static void main(String args[])
{
162 2 double x = 3.14; B 1 0 3 3.0 3.1
int y = (int) Math.abs(x);
System.out.print(y);
}
}
WAP by using else if ladder to print grade of a student using following rules :
Percentage >70 means Grade A
215 3 Percentage 60-70 means Grade B 4
Percentage 50-60 means Grade C
Percentage <50 means Grade F
226 3 What are the keywords used to implement a SWITCH case in JAVA language? D 1 switch case default, break All of the above
L.J Institute of Engineering and Technology, Ahmedabad.
Computer Programming Using JAVA-I Question Bank (SEM-I-2023 CE,IT,CSD,AIML,AIDS,CS&IT,CSE,CST,CEA,RAI Engineering)
Note : This question bank is only for reference purpose. LJU Test question paper may not be completely set from this question bank.
Unit
Sr
Numbe Question_Text MCQ Answer Marks Option A Option B Option C Option D
No
r
What will be the output ?
class MCQ{
public static void main(String args[]){
switch(10){
case 2:
System.out.println("2");
break; Compile time error:
case 13: Compile time error: Case Sequence is
227 3 C 1 Invalid Run time error
System.out.println("13"); Invalid Symbol 10 Wrong. It must start
break; with 1
case 1:
System.out.println("10");
break;
default:
System.out.println("Invalid");
break;}}}
Write a Java program to find the number of days in particular month entered by
user for particular year which is also entered by user,
•You have to take year and month as an input using Command Line Argument.
242 3 6
•Develop the program using Switch case.
•Apply the logic for leap year to find the perfect no. of days.
•Test your Code for Input year:2016 and Month no:2
Write program to input amount from user and print counts of minimum number
243 3 of notes (Available notes in Rs.: 500, 100, 50, 20, 10, 5, 2, 1) required for the 6
amount. (Use Scanner class for user input)
Torrent Power Ltd. charges the following rates for the use of electricity:
First 50 units are free for all;
for the next 150 units 80 paise per unit;
for the next 100 units 90 paise per unit;
beyond 300 units Rs 1 per unit.
245 3 All users are charged fixed Rs. 100 as meter charge. 6
If the total amount is more than Rs 400, then an additional surcharge of 15% of
total amount
is charged. Write a program to read the name of the user, number of units
consumed and print
out the final charged amount.
Write a JAVA program in which take date(DDMMYYYY) from user and display
next day date(DDMMYYYY) as output.
Example:
Input: date=09, month=-06, year=1992
Output: date=10, month=-06, year=1992
246 3 6
Note:-
1. Consider condition for leap year
2. Consider number of days in month of February based on leap year ( if leap
year then February days =29, else days = 28 ) )
3. Consider number of days either 30 or 31 based on month entered by user.