Skip to main content

Java objective question for written Test | Java written test objective question

                               Java objective question
All the best important question
------------------------------------------------------------------------
1.



Answer: Illegal combination of final and abstract class


2.

Answer: 4

3.



Answer:  error: bad operand types for binary operator '=='
                System.out.println("Helo"+10==10);

4.





Answer:  error: integer number too large
                System.out.println(08);


Q5.
====
 class Nit {

public static void main(String[] args) {
m1(2);
}
public static void m1(int i) {
if (i >= 0) {
m1(i - 1);
}
System.out.println(" " + i);
}}




output:
 -1
 0
 1
 2
==================================
Q.2
------
 Question 2: What will be the output of this program:
public class nit1 {
public static void main(String args[]) {
int array[] = new int[10];
for (int i = 0; i < 10; ++i) {
array[i] = i;
System.out.print(array[i] + " ");
i++;
} }}

Output:

0,2,4,6,8

================================
Q.3

Question 3: What will be the output of this program:
public class Array {
public static void main(String args[]) {
int array[][] = new int[3][];
array[0] = new int[1];
array[1] = new int[2];
array[2] = new int[3];
int sum = 1;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
array[i][j] = j + 1;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < i + 1; ++j)
sum += array[i][j];
System.out.print(sum);
}
}

Output:

  11

  ===============================
Q.4

Question 4: What will be the output of this program:
public class Array1 {
public static void main(String args[]) {
char array[] = new char[10];
for (int i = 0; i < 10; ++i) {
array[i] = 'i' + 5;
System.out.print(array[i] + "");
}}}
A) 1 2 3 4 5 6 7 8 9 10  B) 0 1 2 3 4 5 6 7 8 9 10
C) i i i i i i i i i i  D)None Of These

Output:  nnnnnnnnnnnnnnnnnnnnnn
==========================


Q.5
Question 5: What will be the output of this program:
import java.util.*;
public class array2 {
public static void main(String args[]) {
int[] inputArr = { 0, 10, 43, 27, 0, 59, 191, 0 };
int counter = 0;
for (int i = 0; i < inputArr.length; i++) {
if (inputArr[i] != 0) {
inputArr[counter] = inputArr[i];
counter++;
}}
while (counter < inputArr.length) {
inputArr[counter] = 0;
counter++;
}
System.out.println(Arrays.toString(inputArr));
}}

Output:


[10, 43, 27, 59, 191, 0, 0, 0]


Q.6
============================
Question 6: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = new String("hello");
String s2 = new String("helloW");
System.out.println(s1 = s2);
}}
A) True  B)False   C)HelloW   D)hello

Output:
  hellow




=================================

Question 7: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = new String("hello");
String s2 = new String(s2);
System.out.println(s1 == s2);
}
}
A) False   B)True   C) 0   D)CE

Output:
  Variable s2 might be initialized Compile-time error
===============================




Question 8: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = "hello";
String s2 = "hello";
System.out.print(s1 == s2);
System.out.print(" " + s1.equals(s2));
}


A)  False True     B)False False     C)  True True    D)True  False

Output:

  true  true


==================================


Question 9: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = "hello";
String s2 = "hello";
System.out.print(s1.charAt(0) > s2.charAt(0));
}
}
A)  False             B)True                C)  0               D)CE


Output:

  False


==================================


Question 10: What will be the output of this program:
public class string {
public static void main(String[] args) {
String s1 = "hello";
int i2 = 9;
System.out.print(s1 + i2);
}
}
A)  CE            B)True                C)  False              D)hello9      E)9hello
Output: hello9











Comments

Popular posts from this blog

#logicalcoding Write a program to print 1 to 100 number in java | Logic...

Write a program to print 1 to 100 number in java. If you want to become a part of step-by-step to become a logical programmer. Then this video and website for you. So join this website and my youtube channel and become a part of this event. I am going to discuss Java programming in java. become a java logical programmer in java. Software having knowledge about this logic and standard coding practice of these videos. How to become a logical programmer series. Question 3: Write a program to print 1 to 100 number in java. Take one value from the user and print the 1 to n number natural number in java. Code:     import java.util.Scanner; class Numberp  { public static void main(String[] args)  { Scanner sc=new Scanner(System.in); //System.out.println("Enter the Number:");don't used int n=sc.nextInt(); //Validate -ve,+ve,0 if(n<1){ System.out.println("Please enter Valid Number"); System.exit(0); } for(int i=1;i<=n...

Top 100 Logical Question in java | Written test exam question | Logical programming question paper in java to crack the written test exam.

                                  The written  test exam question     If you want to crack the written test exam like TCS , INFOSYS , and WIPRO than you want these questions. this question is very useful for you if you are in college. before any drive for MNC  company you are readily forgiven the exam of this company so, this is for you. This question is very useful for developing logical skills in the programming language. If you want to become a good logical and standard coder than definitely this video for you don't miss this question. As you know logic is the power of the world if you have logic you can solve and find the solution to any type of problem. So, just focus on the logic noting else.         List of Question :       1. Write a Java program to print 'Hello' on screen and then print your name on a separate line. ...

How to earn money online | without investing the money

" How to earn money  online " this is my personal experience. I am going to tell you how you can earn money online. I am not talking about those people who don't have passion, dedication, and education. I am going to talk about those people who want to become a good self employee and who want to earn money online. so, let's start now...         Earn money How you can earn money online ?   This question you have to ask with yourself which area/field you have the interest to become good. for example writing, reading, learning, coding, programming, dancing, singing, cooking, walking, teaching... like so many examples I have, I can so many things about this opportunity. take this anyone of this to become a good than making money online. I am going to teach you how you can do this very easily. How you can achieve this skill . In this world whatever you want to achieve you can achieve no one can stop you, but you have to promise yourself to do ...