Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Java Aptitude Que. & Ans.

Java conditional statements Aptitude Questions and Answers



This section contains Aptitude Questions and Answers on Java Conditional Statements like if else, switch case statement, conditional statements etc.

List of Java Conditional Statements Aptitude Questions

1) Consider the code snippet and select the correct output
if(true && false && true || false)
	System.out.println("True.");
else
	System.out.println("False");
  1. True.
  2. False.

2) What will be the output of following program?
public class temp
{
	public static void main(String args[])
	{
		int x=1;		
		if((boolean)x==true)
			System.out.println("True.");
		else
			System.out.println("False.");
		
	}
}
  1. True.
  2. False.
  3. Error

3) What will be the output of following program ?
public class temp
{
	public static void main(String args[])
	{
		int ok=10;
		switch(ok)
		{
			default:
				System.out.println("default");
			case 0:
				System.out.println("true");
			case 1:
				System.out.println("false");
		}
	}
}

  1. default
  2. Error
  3. true false default
  4. default true false

4) What will be the output of following program?
public class temp
{
	public static void main(String args[])
	{
		boolean ok=true;
		switch(ok)
		{
			case true:
				System.out.println("true");
			break;
			case false:
				System.out.println("false");
			break;
			default:
				System.out.println("default");
			break;
		}		
	}
}
  1. Error
  2. true
  3. false
  4. default

5) What will be the output of following program ?
public class temp
{
	public static void main(String args[])
	{
		int x=1;	
		if(x)
			System.out.println("True");
		else
			System.out.println("False");
	}
}
  1. True
  2. False
  3. Error

Page 2






Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.