QB Java-1 Sem-1 T1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

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
UNIT 1- Decision Making Statement and Branching
TOPIC NAME:- SIMPLE IF STATEMENT (MCQS)
interface between the collection of programs system service
1 1 What is an operating system? D 1 hardware and that manages provider to the all of the mentioned
application programs hardware resources application programs
According to Von Neumann model,what is stored in a memory? neither data nor
2 1 C 1 only data only programs data and programs
programs
Computer Processing Computer Principle
3 1 What is the full form of CPU? C 1 Central Processing Unit Control Processing Unit
Unit Unit
Central Processing Arithmetic and Logic
4 1 Which of the following is the brain of the computer? A 1 Memory Control unit
Unit unit
5 1 The CPU consist of ______ B 1 Input Devices CU and ALU Output Devices none of the above
6 1 Which of the following is/are not input device/s? A 0.5 Joystick Keyboard Trackball Plotter
7 1 Which among following is not necessary for working of a standalone computer? D 0.5 Hard Drive RAM ROM LAN card
TOPIC NAME:- Programming Language (MCQS)
A program that reads each of the instructions in mnemonic form and translates
8 1 B 1 Machine language Assembler Interpreter C program
it into the machine-language equivalent is___
Which of the following is known as the language made up of binary-coded
9 1 D 1 High level BASIC C Machine
instructions?
10 1 Source program is compiled to an intermediate form called ___________ A 1 Byte Code Smart code Executable code Machine code

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

32 1 Write an algorithm and draw a flowchart to print first 50 odd numbers. 4

33 1 Write an algorithm and draw a flowchart to find factorial of given numbers. 4

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

Draw the flowchart to check weather given number by user is palindrome or


39 1 not. 4

Draw flowchart to first check if entered number is 3 digit number or not.


1. If yes, then check and display whether entered number is Armstrong number
40 1 or not. 4
2. If No, then display “Enter three digit Number”

UNIT 2 - Basics of Java


TOPIC NAME:- Features of Java, Byte Code and Java Virtual Machine, JDK, JRE (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
Java is a sequence- Java is a code Java is a platform- Java is a platform-
41 2 Which statement is true about Java? D 1 dependent dependent dependent independent
programming language programming language programming language programming language

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);
}
}

What is the output of the Java code snippet?


class Example
{
public static void main(String args[])
{
163 2 double n=4.5; A 1 Ceil value of 4.5 is 5.0 Ceil value of 4.5 is 5 5 error
double x;
x=Math.ceil(n);
System.out.println("Ceil value of " + n + " is " + x);
}
}
import
164 2 What is the correct path to import Math class in your java file? A 0.5 import java.lang.Math; import java.util.Math; import java.lang.math;
java.math.Math;
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 for the below java code.
class MCQ24 {
public static void main (String args[])
{
double a = 10.86;
165 2 A 1 error 13.86 14.0 10
double b = 3.36;
double ans = Math.floor(10.86) + Math.Ceil(3.36);
System.out.println(ans);
}
}
TOPIC NAME:- Math class and its Methods (PROGRAMS)
Write a program to find out mamximum & minimum number of two numbers
166 2 3
using Math function.
Write a program that prompts the user to enter X and Y to find out XY using
167 2 3
Math function.
UNIT 3- Decision Making Statement and Branching
TOPIC NAME:- SIMPLE IF STATEMENT (MCQS)
168 3 An if statement in JAVA ia also a ------------- statement. B 1 boolean conditional iterative optional
The condition of an if statement evaluates to boolean only if the expression
169 3 D 1 Logical operators Relational operators Boolean operands All
contains -------------.
Choose the correct syntax of JAVA If statement below.
A. if(condition)
//statement
B. if(condition)
{ if(condition)
if(condition)
//statement {
if(condition) {
170 3 } D 1 //statement 1 All
//statement //statement
C. if(condition) //statement 2
}
{ }
//statement 1
//statement 2
}
D. ALL
171 3 What is the output of following program?If(1){System.out.println("OK");} C 1 OK No output Compile error none
What is the output of following program?
int marks=29;
if(marks>=29);
172 3 C 1 PASS RANK PASS RANK Compile error
System.out.print("PASS");
System.out.println("RANK");

What is the output of following program?


int a=10,b=20;
if(a==10)
FOX FOX GOOD
173 3 System.out.print("FOX"); B 1 Compile error None
DINO DINO
System.out.println("GOOD");
if(b==20)
System.out.println("DINO");
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 program?
If(true)
{
174 3 C 1 No output ELEPHANT Compile error none
break;
System.out.println("ELEPHANT");
}
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
175 3 int a=10; C 1 10 10 10 a=10 a=10 a=10
if(a!=10)
System.out.println("a=10");
System.out.println("a=10"); }}
TOPIC NAME:- SIMPLE IF STATEMENT (PROGRAMS)
176 3 Write a program to check given digit is an odd or even using simple if statement. 3
Write a program to check given digit is an positive or zero using simple if
177 3 3
statement.
TOPIC NAME:- IF ELSE STATEMENT (MCQS)
Give output
int Output=10;
boolean b1 = false; Compile error,
Compilation and Compilation and
if((b1==true) && ((Output+=10)==20)){ attempting to perform Compilation and
178 3 C 1 output of "We are output of "Not equal!
System.out.println("We are equal "+Output); binary comparison on output is Not equal! 10
equal 10" 20"
}else { logical data type
System.out.println("Not equal! "+Output);
}
What is the output of the Java code snippet?
class Main{
public static void main(String args[])
{
int a=6, b=5;
179 3 if(++b == a--) { B 1 BUNNY RABBIT BUNNY RABBIT Compiler error
System.out.println("RABBIT");
}
else{
System.out.println("BUNNY");
} }}
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
int a=50;
180 3 if(a) D 1 a=50 a!=50 a==50 Compile error
System.out.print("a=50");
else
System.out.println("a!=50");
}}
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
Find the output of the given Java program?
public class Main
{
public static void main(String[] args) {
boolean x, y, z;
x = y = z = true;

181 3 if(!x || (!y && !z)) D 1 Hi Hey Hey Hello Error


System.out.println("Hi");
System.out.println("Hey");
else
System.out.println("Hello");
}
}

What is the output of the Java code snippet?


class Test1{
public static void main(String []demo){
int num1 = 10, num2 = 8;
if (num1 < num2){
int calculate = 10 / 12 * 3 - 4 | 3;
182 3 System.out.println(calculate); C 1 10 -1 10.0 Error
}
else if(num2 != num1) {
double calculte = 10 | 8 >> 2 * 2;
System.out.println(calculte);
}
}}

What is the output of Java program below?


float temp = 98.4f;
if(temp > 98.4)
{
System.out.print("SUMMER ");
System.out.println(temp+++"," +temp);
183 3 A 1 SUMMER 98.4,99.4 UNKNOWN 98.4,99.4 UNKNOWN 99.4,99.4 SUMMER 99.4,99.4
}
else
{
System.out.print("UNKNOWN ");
System.out.println(temp+++"," +temp);
}
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 Test{
public static void main(String[] args){
int a=5,b=6;
if(!true){
System.out.print("ELEPHANT");
a=a&b;
184 3 if (a!=b){ A 1 TIGER6 -6 ELEPHANT6 -6 ELEPHANT7 -6 error
b=~++a;
System.out.println(a+" " +b);}}
else{
System.out.print("TIGER");
b=~a++;
System.out.println(a+" " +b);
}}}
What is the output of following program?
class Test1{public static void main(String[] args)
{
185 3 C 1 TRUE FALSE Error true
If(false){
System.out.println("true");}
}}

What is the output of the Java code snippet?


int Output=10;
boolean b1 = false;
if((b1==true) && ((Output+=10)==20)){
186 3 System.out.println("We are equal "+Output); A 1 Not equal! 10 "We are equal 10" "Not equal! 10" "Not equal! 20"
}
else {
System.out.println("Not equal! "+Output);
}

What is the output of the Java code snippet?


int y = 7;
if (-5 >= -2){
System.out.printf("y is %d\n", y++);
187 3 B 1 7 8 Error No error & No output
}
else
System.out.printf("%d\n", ++y);
}
Which of the following lines of code will compile without error?

188 3 B 1 Code 1 Code 2&4 both Code 3 Code 4


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 a=5, b=10;
if(++b>10 || a++==5)
189 3 { A 1 PIZZA=5 PIZZA=6 BURGER=5 BURGER=6
System.out.println("PIZZA="+a);
}
else
{
System.out.println("BURGER="+a);
}}}
What is the output of following program?
int a=10,b=20;
if(a==1)
190 3 System.out.print("FOX "); A 1 GOOD DINO FOX GOOD DINO FOX GOOD DINO
System.out.print("GOOD");
if(b==20)
System.out.println(" DINO");
What is the output of the Java code snippet?
int x = 7, z, y = ~x;
if(x < y ? false : true){
z = x > y ? x : y;
System.out.print(z+ ++z);
191 3 C 1 7 8 15 16
}
else{
z = x < y ? x : y;
System.out.print(z+=++z);
}
What is the output of the following Java Code snippet?
int x = 9;
192 3 C 1 LJIET JAVA ERROR "JAVA"
if (x = 9) {System.out.print("LJIET");}
else {System.out.print("JAVA");}
193 3 An If-else statement is also called---------. D 1 Branching Statement Control Statement Block Statements All

What is the output of following program?


If(TRUE)
{
System.out.println("GO");
194 3 C 1 GO STOP Compile error none
}
else
{
System.out.println("STOP");}
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 program?
int a=10;
If(a==9)
195 3 System.out.println("GO"); C 1 GO MASTER BYE Compile error None
System.out.println("MASTER");
else
System.out.println("BYE");

What is the output of the following Java Code?


class Test {
public static void main(String[] arg) {
int a = 10;
int b = ++a;
if(a<11)
196 3 D 1 a is less than 11 a is equal to 11 a is greter than 11 Compile time error
System.out.println("a is less than 11");
else if(a=11)
System.out.println("a is equal to 11");
else
System.out.println("a is greter than 11");
}}

What is the output of the following Java Code?


class LJU {
public static void main(String[] arg) {
int a = 10;
int b = ++a;
197 3 int c = b++; D 1 a and c are equal a and c are not equal 11 and 11 are equal Compile time error
if((a<b) <= (c<b))
System.out.println("a and c are equal");
else
System.out.println("a and c are not equal");
}}
TOPIC NAME:- IF ELSE STATEMENT (PROGRAMS)
WAP to determine a given number is ‘odd’ or ‘even’ and print the following
198 3 5
message “Number is ODD” or “Number is Even” with using if else statement.
WAP to check whether entered number is divisible by 5 or not by using if…else
199 3 3
statement.
200 3 W.A.P.to test the char you have inserted is alphabet or digit. 3
201 3 WAP that determines if a year is a leap year or not by using if…else. 4
WAP to check whether entered character is vowel or not by using if…else
202 3 4
statement
W.A.P.to find root of quadratic equation : -
203 3 5
R1 : b+sqrt((b*b)-4*a*c)/(2*a) R2: -b-sqrt((b*b)-4*a*c)/(2*a)
TOPIC NAME:- NESTED IF ELSE STATEMENT (PROGRAMS)
WAP to accept three numbers from user and Print Maximum number by using
204 3 4
nested if..else
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
WAP to check whether a person eligible for blood donation or not by using
205 3 Nested If Statement. Condition for eligibility is person weight >50 and person 4
age >18 .
TOPIC NAME:- ELSE IF LADDER (MCQS)
What is the output of the Java code snippet?
class Test{
public static void main(String args[]) {
int marks=55;
if(marks>=80)
206 3 System.out.print("DISTINCTION"); D 1 pass fail PASS FAIL
else if(marks>=35 && marks<=50)
System.out.println("PASS");
else
System.out.println("FAIL");
}}
What is the output of the following code?
class MCQ {
public static void main (String args[])
{
int a = Integer.parseInt("25");
int b = Integer.parseInt("50");
double ans = (double)a/b;
207 3 if(ans==0){ B 1 ZERO Compile error FIVE Hello Hello
System.out.print("ZERO");}
else if(ans==0.5){
System.out.print("FIVE");}
System.out.println("Hello");
else{
System.out.print("ELSE PART");
}}}
208 3 An if or else if statement accepts--------- as input before branching. A 1 boolean int float char
209 3 An else statement in JAVA must be preceded by ------------- statement. C 1 if else if if or else if none
What is the maximum lines of code that can be written inside a JAVA style if-else
210 3 D 1 32 64 512 none
or else if block?
What is the maximum number of else-if statements that can present in between
211 3 D 1 32 64 128 none
starting if and ending else statements?
What is the output of following program?
int marks=55;
If(marks>=80)
System.out.print("DISTINCTION");
212 3 B 1 DISTINCTION PASS FAIL None
else if(marks>=35)
System.out.println("PASS");
else
System.out.println("FAIL");
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 program?
int marks=90;
If(marks>=80)
213 3 System.out.print("DISTINCTION"); A 1 DISTINCTION PASS FAIL None
else if(marks>=35)
System.out.println("PASS");

What is the output of following program?


int horses=10;
int camels=5;
If(horses>5)
{
if(camels>3)
214 3 A 1 FOREST CITY Compile error none
{
System.out.print("FOREST");
}}
else
{
System.out.println("CITY");}
TOPIC NAME:- ELSE IF LADDER (PROGRAMS)

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

WAP to perform addition, multiplication, subtraction and division according to


216 3 4
user choice using else if ladder.
W.A.P.to checK whether entered number is positive nagative or zero by using
217 3 4
else….if ladder.
TOPIC NAME:- SWITCH STATEMENT (MCQS)
218 3 A SWITCH case statement in JAVA is a ---------- control statement. C 1 Iteration Loop Selection Jump
219 3 Which is the alternative to SWITCH in JAVA language? D 1 break,continue for,while goto,exit if,else-if,else
What is the output of following program?
int a=10;
switch(a)
220 3 B 1 No output TEN Compile error None
{
case 10: System.out.println("TEN");
}

What is the output of following program?


int b=20;
switch(b)
221 3 B 1 No output LION Compile error None
{
default: System.out.println("LION");
}
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 program?
String animal="GOAT";
switch(animal)
222 3 D 1 No output GOAT DOMESTIC Compile error
{
break: System.out.println("DOMESTIC");
}

What is the output of following program?


int num=40;
switch(num)
{
223 3 B 1 FIVE FORTY FIFTY Compile error
case 5: System.out.println("FIVE"); break;
case 35+5: System.out.println("FORTY"); break;
case 20+30: System.out.println("FIFTY"); break;
}

What is the output of the Java code snippet?


class Test{
public static void main(String args[]) {
double x=1.0;
switch(x)
{
224 3 D 1 1.01 1 1.0 1.0 Compile error
case 1.0:
System.out.print(x);
default:
System.out.print("1");
}
}}

What is the output of the Java code snippet?


class Test{
public static void main(String args[]) {
int a=10;
switch(a)
{
225 3 C 1 TenNineEight TenNineEightEleven TenNine Ten
case 10:System.out.print("Ten");
case 9:System.out.print("Nine");break;
case 8:System.out.print("Eight");
case 11:System.out.print("Eleven");
}
}}

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;}}}

What is the output of the Java code snippet?


class Test1{
public static void main(String args[]){
int num1 = 10, num2 = 120;
boolean FALSE = !false;
double N = num2 / num1;
if (FALSE)
switch(N){ TWELVE
228 3 D 1 TWELVE TEN ERROR
case 11: DEFAULT
System.out.println("ELEVEN");
case 012:
System.out.println("ONE TWO");
case 12:
System.out.println("TWELVE");
default:
System.out.println("DEFAULT");} }}

What is the output of the Java code snippet?


class ArithOp{
public static void main(String[] args){
int a=7, b=5;
switch(a = a % b){
229 3 case 1: a = a - b; B 1 5 7 9 2
case 2: a = a + b;
case 3: a = a * b;
case 4: a = a / b;
default: 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 the Java code snippet?
class Test{
public static void main(String[] args){
double discount;
char code = 'C' ;
230 3 switch ( code ){ C 1 0.1 0.2 0.3 0.4
case 'A': discount = 0.0;
case 'B': discount = 0.1;
case 'C': discount = 0.2;
default: discount = 0.3;}
System.out.println(discount);}}

What is the output of following program?


String animal="break";
231 3 switch(animal){ D 1 animal "DOMESTIC" DOMESTIC Compile Error
break: System.out.println("DOMESTIC");
}
What is the output of the Java code snippet?
int b = 10;
String a = "break;";
switch(++b){
case 11: System.out.print(a);
232 3 case 12: System.out.print(" BEST"); break; A 1 break; BEST BEST break Error
case 13: System.out.print(" OF"); break;
case 14: System.out.print(" LUCK"); break;
case 15: System.out.print(" FOR"); break;
case 16: System.out.print(" EXAM"); break;
}

What is the output of the following Java Code snippet?


int x = 3;
switch (x)
{default: System.out.print("def");
233 3 A 1 def01 0 2 3
case 0: System.out.print("0");
case 1: System.out.print("1");break;
case 2: System.out.print("2");
}

What is the output of the following Java Code snippet?


byte x = 25;
switch (x)
234 3 C 1 LJIET JAVA ERROR "JAVA"
{case 10: System.out.print("LJIET");
case 25: System.out.print("LJU");
case 1000: System.out.print("JAVA");}

TOPIC NAME:- SWITCH STATEMENT (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
WAP by using switch case to print grade of a student using following rules :
Percentage >70 means Grade A
235 3 Percentage 60-70 means Grade B 5
Percentage 50-60 means Grade C
Percentage <50 means Grade F
WAP to perform addition, multiplication, subtraction and division with Switch
236 3 5
statement.
WAP that reads number from 1 to 7 and accordingly it should print MONDAY to
237 3 5
SUNDAY by using Switch statement.
WAP to enter a character and check whether it is a vowel or consonant using
238 3 5
switch statement
TOPIC NAME:- ALL CONDITIONAL STATEMENT (PROGRAMS)
Write a program for given below information:
A student will not be allowed to sit in exam if his/her attendance is less than
75%.
Take following input from user using scanner class.
1.Number of classes held (Take int datatype)
2.Number of classes attended (Take int datatype)
239 3 And print percentage of class attended in real data type. 6
If student has not any medical cause and attendance criteria not fulfilled then
directly print “ You are not eligible to sit in exam”.
Allow student to sit if he/she has medical cause Ask user if he/she has medical
cause or not ( 'Y' ,’y’ for Yes or 'N', ’n’ for No) in char form and attendance
>=60% and <=74%, then print message “You can sit in exam” otherwise print
“You are not eligible to sit in exam”.
Write a Java program to input electricity unit charges and calculate total
electricity bill
according to the given condition:
For first 50 units Rs. 0.50/unit
240 3 For next 100 units Rs. 0.75/unit 6
For next 100 units Rs. 1.20/unit
For unit above 250 Rs. 1.50/unit
An additional surcharge of 20% is added to the bill. Use Scanner class for input
of electricity units.
Write a java code to perform following task.
Adani Gas Company Limited has increased price per unit Rs. 5 in every slab of
unit usage from the month of October. My Previous Bill of September is 1774.86
with Usage of 150 Unit & Including 18% GST. Use Scanner class to take
no_of_unit as user input and calculate my bill for the month of October. Also
check the difference of final bill amount from the month of September and
241 3 Ocotber. 6
Unit Usage Price Per Unit (Before Month of October)
0 – 50 02
51 – 250 10
250 – 350 13
350 - 500 18
> 500 25
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 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)

Write a Java program for the following:


Accept any three-digit number from the user and display the message which
244 3 digit is maximum using else-if ladder. Also swap second and third digit if the first 6
digit is in a range of 0 to 5, calculate Average of first, second and third digit if the
first digit is in a range of 6 to 9 using switch statement.

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.

You might also like