java Assignment1
java Assignment1
class Java
{
public static void main(String[] args)
{
test('a');
}
public static void test(int a)
{
System.out.println("int");
}
public static void test(double d)
{
System.out.println("double");
}
}
a) double
b) int
c) Compile Time Error
d) None of the Above
a) return 10>20 ;
b) return 'a'+10;
c) return (int a = 10);
d) return 10>20 ? 10 : 20;
a) 20
b) compile time error
c) 10
d) None of the Above
a) Interpreter
b) JIT
c) Java Compiler
d) JVM
a) import java.lang.Scanner;
b) Import java.util.Scanner;
c) import java.util.*;
d) import java.util.Scanner;
9) Which members can be called from one class into another class?
10) which one is the correct when the return type of the method is void
a) a
b) 97
c) Compile time error
d) None of the Above
a) Value
b) Variable
c) Statement
d) Expression
a) Static variables
b) Local variables
c) non static variables
d) None of the Above
a) No output
b) Compile time error
c) 30
d) None of the Above
a) byte>short>int>long>float>double
b) byte<short<int<float<long<double
c) byte<short<int<long<float<double
d) byte<short<int<float<double<long
18) What is the output for the following program
class Java5
{
public static void main(String[] args)
{
int a = 10;
test(10+"Perseverence");
}
public static void test(String b)
{
System.out.println("All the best");
}
}
a) No output
b) Compile time error
c) It will not execute
d) All the best
a) JVM
b) Java compiler
c) Programmer
d) JIT compiler
a) Type casting
b) Self Updating
c) Reduce code redundancy
d) All of the Above
a) 13
b) 8
c) Compile time error
d) None of the Above
a) 22
b) 21
c) Compile time error
d) 20
24) What should be the operand for Increment and Decrement operator
26) What we cannot use in the place of Operand2 and Operand3 in Conditional
Operator
a) Expression
b) Statement
c) data
d) Variable
28)
int a = 10;
int b = 20;
int res = a+b;
What is the correct expression we have to use to print the output like 10+20=30
a) a+b=res
b) a+"+"+b+"="+res
c) a"+"b"="res
d) We cannot print like 10+20=30
29) Which one is not the behavior of the Operator in java
a) &&
b) ++
c) +
d) %
a) Dot(.) Operator
b) Compound Assignment operators
c) Relational operators
d) Arithmetic Operators
a) Class members
b) Object members
c) Both (a) and (b)
d) None of the Above
a) keyword
b) identifier
c) Literal
d) Symbol
a) Predefined Word
b) Reserved word
c) Compiler aware word
d) All of the Above
-----------------------------------------------------------------------------------
---------------------------------------------------
6)
int a = 10;
int b = 20;
int res = a+b;
What is the correct expression we have to use to print the output like 10+20=30
a) a+b=res
b) a+"+"+b+"="+res
c) a"+"b"="res
d) We cannot print like 10+20=30
7 ) Which operator will have polymorphic nature
a) &&
b) ++
c) +
d) %
9) What is keyword
a) Predefined Word
b) Reserved word
c) Compiler aware word
d) All of the Above
a) keyword
b) identifier
c) Literal
d) Symbol
a)1021
b)1122
c)1121
d)1020
19) What is the correct syntax of the conditional (ternary) operator in Java?
22) Which of the following data types is used to store a decimal number in Java?
a) int
b) double
c) boolean
d) char
23) Which of the following is the correct way to declare a float variable in Java?
a) float f = 10.5;
b) float f = 10.5f;
c) float f = 10.5F;
d) Both 2 and 3
24) What is the output for the following program
public class Main {
public static void main(String[] args) {
int x = 5;
{
int x = 10;
System.out.print(x);
}
System.out.print(x);
}
}
a) 105
b) Compilation Error
c) 1010
d) None of the above
29) Can we compile an empty Java source file (without any code) in Java?