All Topics
Topic26 questions
3. Class And Objects, Date ApiQuestions & Answers
Practice 26 3. Class And Objects, Date Api questions with detailed answers and explanations. Tap any question below to study the full solution.
3. Class And Objects, Date Api question list
Which of the following is not a Java modifier?Predict the output. class X { void display(int a) { System.out.println("INT"); } void display(double d) { System.out.println("DOUB…Integer x1 = new Integer(120); int x2 = 120; System.out.println( x1 == x2 ); What will be the output of the above code fragment?Observe the code public class Sample { public static void main(String [] args) { int x = 6; Sample p = new Sample(); p.display(x);…Given classes defined in two different files: 1. package p1; 2. public class Test { 3. public static void display(String [] a) { /…The methods of a class with the ____________ access specifier cannot be accessed in its subclass class of different package.What is the outcome of the code? public class Item { private String description; public String getDescription() { return descripti…Given: public class Message { String msg; int noOfWords; public Message() { msg += " Thank you"; } public Message(int noOfWords) {…Predict the output. public class Test { public static void main(String args[]) { int a = 2, b = 0; for ( ; b < 20; ++b) { if (b % …Eclipse IDE, if we provide a workspace, it should already exist. If not, it will not open.What will be the output of the following code? int i=20; if(i>10) { System.out.println( "The value of i is "+i); i++; if(i%2!=0) b…switch(a) { default: System.out.println("Welcome"); } Of which data types can the variable a be? 1. long 2. byte 3. int 4. char 5.…State True or False When using eclipse whichever classes are needed for the present class can be imported automatically.___ and _____ are the access specifiers that can be applied to top level Class.class Sample{ private double num = 100; private int square(int a){ return a*a; } } public class Test{ public static void main(Stri…Choose the appropriate access specifier for the attribute value so that it can be accessed from anywhere. class Test { public int …Consider the below code snippet and determine the output. class Student { private int studentId; private float average; } class Te…The below code snippet shows an error cannot find symbol: System.out.println("BookId:"+bobj.getId()); public class Book { private …Observe the below code. public class Student { private int id; private String name; private char grade; //Constructor 1 public Stu…Observe the code below. public class Student { int studentId; String name; char grade; public Student(int studentId, String name, …Observe the below class. class Product{ int productId; String productName; Product { productId=0; productName= ; } Product(int id,…Given the class Book in packages p1 and class Main in package p2. In main to create an object of Book, which of the following are …Given the class Book and Library in two different packages : 1. package model; 2. public class Book { 3. private static void count…Choose the correct order of the Java code fragments: 1) public class Main, 2) import java.util.Scanner;, 3) {, 4) // Some code her…Assume class Calculator in package p1 and CalculatorService class in package p2 as shown below. package p1; public class Calculato…For the below code, what are the valid ways to invoke display method in the main method. public class Test { public static void di…Practice more topics
PrimerPrep has independently reviewed practice questions and coding exercises — all free.