forked from Inayat61/Hactoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestionForJava.txt
More file actions
66 lines (52 loc) · 1.08 KB
/
QuestionForJava.txt
File metadata and controls
66 lines (52 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Q1:How to print the data on console?
Ans: using System.out.println("data");
Q2:What is Class in Java?
Ans: Blueprint of object.
Q3:If We have a class named as Work with default constructor then how we will
create the object?
Ans: Work w = new Work();
Q4:What is Objects in Java?
Ans: instance of class.
Q5: Create an Integer Variable ?
Ans: int idk_man;
Q6: Write any String class function down here?
Ans: String s = "Hey";
s.charAt(1);
Q7: How many classes we can extends in java?
Ans: 1
Class Test{
public static void main(String[] args){
int r = 3;
System.out.print.ln("R= "+r);
}
}
Class TestInner{
public static void main(String[] args){
String s = " Hey. ";
System.out println(s.trim());
}
}
class Test2
class Test3
{
public static void main(String[] args){
int r = 3;
int i= 2;
int j=r-i;
System.out.println("J="+j);
int k=r+i+j;
System.out.println(k);
}
}
class factorial
{
public static void main(String args[])
{
int fact=1;
for(int i=4;i>0;i--)
{
fact*=i;
}
System.out.print("fact"+fact);
}
}