Search Placementyogi.com
 

Difficult Questions on Operators in Java Objective Questions

  :: Topics ::

1

What is the output of the following program?

class ModulusOperators1 
{
	public static void main(String[] args) 
	{
		double d=2.8;
		System.out.println("2.8%1.2 ="+ d%1.2);
	}
}
A.

0.4

B.

Compilation Error

C.

0

D.

None of the Above

See Answer & Explanation Lets Discuss
Correct answer is : D
Explanation

The correct output is:

2.8%1.2 =0.3999999999999999

This is strange but for precision concerns the output is not 0.4 but 0.399999999.

 
2

What is the output of thefollowing program?

class Operators1 
{
	public static void main(String[] args) 
	{
		double x=6;
		int y=5,z=2;
		x= y++ + ++x/z;
		System.out.println(x);
	}
}
A.

9

B.

8

C.

8.5

D.

None of the Above

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

++ has higher precedence than division. So, ++x is executed first and then division is performed.

x= 5+ 7/2 = 5 + 3.5= 8.5

 
3

What is the output of the following program?

class Operators1 
{
	public static void main(String[] args) 
	{
		int x =5;
		x *=  2 +5;
		System.out.println(x);
	}
}


A.

15

B.

35

C.

Compilation Error

D.

None of the Above

See Answer & Explanation Lets Discuss
Correct answer is : B
Explanation

x*=2+5

=> x=x*(2+5)

=> x=5 * (7)

x=35

 
4

What is the output of the following program?

class Class1
{
}
class Operators1 
{
	public static void main(String[] args) 
	{
		Class1 myobj= new Class1();
		System.out.println(myobj instanceof Operators1);
	}
}
A.

True

B.

False

C.

Compilation Error

D.

None of the Above

See Answer & Explanation Lets Discuss
Correct answer is : C
Explanation

instanceof operator cannot be used across different class hierarchies. 

Operators1.java:9: error: inconvertible types

               System.out.println(myobj instanceof Operators1);

                                  ^

 required: Operators1

 found:    Class1

 
 

Banner to LogicGuns.com

Hide Page Information

Java Difficult Operators in Java Objective Questions and Answers for Written Round Interview

Here you can find Java Difficult Operators in Java Objective Questions with answers and explanation. We have a vast collection of Objective Questions on tough Operators in Java in Java that will help you a lot!

Why learn Java Difficult Operators in Java?

Difficult Operators in Java are an integral part of Java and many Objective Questions in the written round are asked from this topic.In this section you can learn and practice Java Difficult Operators in Java (Objective Questions with Answers) to improve your skills in order to face the interview and clear campus and off-campus selection of TCS, Infosys, Wipro etc.

Where can I get Java Difficult Operators in Java Objective Questions and Answers with Explanation?

PlacementYogi provides you lots of fully solved Java Difficult Operators in Java Objective Questions and answers with explanation. Fully solved examples with detailed answer description, explanation are given and it would be easy to understand.Though we do not have pdf file for Java Difficult Operators in Java, We have quiz Objective Questions with answers to help you test yourself..

\n

Where can I get Java Difficult Operators in Java Interview Objective Questions and Answers (objective type, multiple choice)?

Here you can find objective type Java Difficult Operators in Java Objective Questions and answers for interview and entrance examination.Multiple Answers and true or false type Objective Questions are also provided.

How to solve Java Difficult Operators in Java problems?

You can easily solve all kind of Objective Questions based on Java Difficult Operators in Java by practicing the exercises (including shortcut Difficult Operators in Java to solve problems) given below.