JAV
JAV
23 Java Programming
Standalone assignment
CA-1
Submissions
Question 1
class strreplace{
System.out.println(replacestr):
Response: MynameisJava
Question12
class abe
System.outprintln(args|o|);
Response: Error
Score: 0 out of 1 No
Question 3
class str3
System.outprintin(sl.endsWith("g"):
System.out.println(sl.ends With("a"));
System.out.println(sl.ends With("ing"));
Response: true
false
false
true
ole
Taise
Ialse
true
Question 4
class example
System.out.println(s .substring(2,6));
System.out.println(s .substring(2);
Question 5
class abe
for(int i-=0;:i<args.length;i++)
System.outprintln(args[i):
bbb
ddd
eee
Score: 0 out of I No
Question 6
import java.util.Scanner
class enpoyee
e" Console.nextline0:
/ ad
gender console.next0.charAt(O):
W read salary
alaryconsoleevtDosled
Age 34
Gender: Male
Salary: 56789
Correct answer:
Age: 34 Gender: M
Salary: 56789.0
Score: 0 out of 1 No
Question 7
class strcompare
String s2="hello";
System.out.println(s1.compareTo(s2);
Response: 18
orrect answer: 18
Question 8
class test
String a="HELLO";
System.out.println(a);
Score: 0 out of 1 No
Question 9
class Test {
String sl = "HELLO";
String s2 = "HELLO":
System.out.println(s l=S2);
System.out.println(sl =S3);
System.out.println(sI.equals(s2);
System.out.println(s l.equals(s5);
Response: true
false
true
true
Correct answer: true
Ialse
rue
true
Question 10
How many bytes are allocated for int data type in Java?
Response:4
Correct answer: 4
Question 11
class ForCheck
for(int i=1;i<=5;it+)
for(int j=-5;j>=lj-)
System.outprint(+ "++
Response:
5,444342,4 15
5,5 45 35 251,
correct answer:
5444 342415
55 4,5 3,525 1,
class ForCheck
for(int i=1;i=5:it+);
for(int j= 1j=5jt+)}
System.outprint(+ +)
Score: 0 out of I No
Question 13
class test
int a,bcd;
d=a
Class Pqr
test t2,13;
t3=t2=tl;
System.out.println(t3.d);
Correct answer: 30
Score: 0 out of 1 No
Question 14
class Strtoint
int i=nteger.parseInt(s);
System.outprintin(S +526)
System.out.println(i+210);
Response: 123526
333
Score: 0 out of 1 No
Question 15
class test
System.out.println("Hello");
Question 16
Response: Compiler can call it without the creation of an object or before the creation of an
object of the class.
Correct answer: Compiler can call it without the creation of an object or before the creation of
an object of the class.
Question 17
class Demo{
System.out println(final):
Question 18
class abe
System.out.println(args.length);
Response: Error
Correct answer: 4
Score: 0 out of 1 No
Question 19
class x
char ch=name.charAt(5);
System.out.println(ch);
Response: F
orrect answer: F
Question 20
class ForCheck
int s
for(int i=1j=5;i<=5ittj-)
s=S+(1+j);
System.out,println(s);
Score: 0 out of I No
Question 21
class string9
String s1="ABCDEFGHIJ";
byte ar[]=slgetBytes0
System.outprintin(ar|[7);
Find output
Response: 72
Correct answer: 72
Question 22
class one
public static void main(String argll)
class two
class three
w w woo.
For the following java file, how many class file will create?
tollowing commanas
java on
the
Question 23
class test
int a,b.c:
a=x;b=y:cZ; a=atb+cC;
System.out.println(a):
test(int x, int y)
a=x; b
=10; a=at+b+C;
System.out.println(a);
test(int x)
a=x; b=10;
=10; a=atb+C;
System.out.println(a);
class
Pqr
Response: 30
S0
Correct answer: 30
S0
30
Question 24
class ForCheck
for(int i=1j=5;i=5ittj-)
System.outprintln(1+" +)
Correct answer: 15
33
51
Score: 0 out of I No
Question 25
class xyz{
String name="ABCDEFG":
System.out.println(name|2]);
Question 26
class xyz{
String name="ABCDEFG";
char|] ch=name.toCharArray0;
System.out println(ch[2]D:
Response: C
orrect answer: CC
Question 27
String name;
student(int r, String s)
rollno=r;
name=s;
class xyz
student thirdstudent=secondstudent
if(thirdstudent.equals(secondstudent))System.out.printin("True
if(secondstudent.equals(firststudent))System.out.println("True2");
if(fourthstudent.equals(firststudent) )System.out.printin("True3");
if(fourthstudent-=firststudent)System.out.println("True4");
if(thirdstudent==secondstudent)System.out.println("True5");
Response: Truel
Trues
True4
Trues
Score: 0 out of 1 No
Question 28
class string4
From the above program, remove trim) method and find the output
Question 29
class Demo{
int b=att;
ystem.out.printin(a);
System.out.println(b)
Kesponse: 11
Correct answer: IT
10
Question 30
class abe
int sum=0
sum=sum+Integer.parselnt(args{i|);:
System.out.printn(sum);
java arg3.java 10 20 30 40
Response: 10
Correct answer: 1000
Score: 0 out of 1 No
Home
Semesters
Standalone assignment
CA-2
Submissions
Question 1
Question 2
class example
System.out.println(sI.substring(2,6)
System.outprintin(sl .substring(2))
Response: CD E
CD EFG HIJK
CD EFG HIJK
Question 3
For throwing user defined exception, which class is extending?
Response: Exception
Question 4
double tjava.lang.Math.sqrt(x);
Response: Math
Question 5
Response: Compiler can call it without the creation of an object or before the creation of an
object of the class.
Correet answer: Compiler can call it without the creation of an object or before the creation of
an object of the class.
Question 6
Response Implements
Question 7
Response: interfaces
class forcheck
for(int i=1;i=5;i++)
for(int j=lj<=ij+)
System.out.print(i);
System.out.println("")
Response:1
4444
55555
Correct answer: I
4444
55555
Score: 1 out of 1 Yes
Question 9
Question 10
Response: stop()
Question 11
Which package is helpful in implementing GUI?
Response: java.awt
https://learn.jainuniversity.ac.in/student_quiz_assignment/submissions/33639229 2/9
Question 12
class strtoint
String s"123";
int i-Integer.parselnt(sS
System.out.println(s+526);
System.out.println(it+210);
333
333
Question 13
class strcompare{
String sl=""zello"
String s2=""hello";
System.out.println(sl.comparc'To(s2);
Response: 18
Correct answer: 18
Question 14
Which is representing current instance of a class ?
Response: this)
Question 15
Question 16
"class test
Question 17
What will happen to currently running thread, If thread of a higher priority comes?
Response: Preempted
https://learn.jainuniversity.ac.in/student_quiz_assignment/submissions/33639229 3/9
Question 18
Which method is called in java to reclaim the space for that object?
Response: Finalize()
Question 19
Response: Package
Question 20
"class abec
System.out.printin(args.length);
Find the output if the execution command is like this
Response:4
Correct answer: 4
Question 21
Response: NullPointerËxception
Question 22
Response: private
Correct answer: private
Question 23
class xyz
String name-"ABCDEFG"
char[] ch=name.tocharArray O;
System.out.printin(chnl2])
Response: C
Correet answer: C
https://learn.jainuniversity.ac.in/student_quiz_assignment/submissions/33639229 4/9
Question 24
class exp
intiInteger.parselnt(""abc""
Ccatch(Exception ex)
catch(NumberFormatException ex)
Correct answer: Compilation error: exception NumberFormatException has already been caught
Question 25
Response: Usage of pointers can make it challenging. Pointer utilization can also cause
potential memory errors.
Correct answer: Usage of pointers can make it challenging. Pointer utilization can also cause
potential memory erTors.
Question 26
Response: Runnable
Question 27
class forcheck
int s
for(int i= 1j=5;i=5;ittj-)
s-st(i+j);
System.out.printn(s);
Correct answer: 30
Question 28
class A
System.out.println("class A");
https://learn.jainuniversity.ac.in/student_quiz_assignment/submissions/33639229 5/9
class B extends A
void display0
System.out.println("class B");
b.displayO0
Response: Program Won't compile: cannot override display method which is final
Correet answer: Program Won't compile: cannot override display method which is final
Question 29
Response: Runnable
Question 30
The capability to control the access of multiple threads to any shared resource is called?
Response: Synchronization
Question 31
Response: start()
Question 32
class B
body of class B
Response: Default
Correct answer: Default
Question 33
Question 34
class test
https://learn.jainuniversity.ac.in/student_quiz_assignment/submissions/33639229 6/9
nt a-25;
int b=0;
ry
int c= a/b;
tinally
System.out.println("In finally");
Response: In finally
at test.main
at test.main
Question 35
Response: FileNotFoundException
Question 36
class string9
String sl=""ABCDEFGHIJ";
byte ar[sl.getBytes():
System.out.println(ar[7]);
Find output
Response: 72
Correet answer: 72
Question 37
Which class that implements an interface does not implement all the methods of the interface?
Question 38
Question 39
Response: Multiple
https://learn.jainuniversity.ac.in/student_quiz_assignment/submissions/33639229 7/9
8/8/22, 11:36 PM Submissions Semesters CA-2-
Question 40
class abe
System.out.println(args[O]);
Response: 111
Correct answer: l
Question 41
Class test
int b-0;
try
a/D,
Question 42
class A
class B extends A
class C extends B
COSystem.out.println"ln Class C"):}
class testl
C objc=new CO:}
Response In Class A
Class B
n Class
n lass B
In lass C
Question 43
class a
int sum=0
for (int i=0;i<args.length;it+)
sum-sum+lnteger.parselnt(args[1]);
https://learn.jainuniversity.ac.in/student_quiz_assignment/submissions/33639229 8/9
System.out.println(sum);
java arg5.java 10 20 30 40
Response: 100
Question 44
Which classes are used as super classes whose properties are inherited by classes?
Response: Interfaces
"class test
String a=""HELLO""
System.out.println(a)
https://learn.jainuniversity.ac.in/student_quiz_assignment/submissions/33639229 9/9